included do
where state: states.map(&:to_s)
}
end
# override if necessary
end
# Sidekiq requeues the current job automatically
else
else
end
end
# Can really happen (SQL Exceptions, etc.)
error = "Nested exception on updating state of #{self.class} #{id}\n"
error << "#{e.class}: #{e}\n " << e.backtrace.join("\n ")
# Update attributes without any callbacks
self.class.where(id: id).update_all \
state: 'failed',
state_updated_at: Time.now,
last_error: error
# re-raise
raise
end
raise
end
end
def update_state!(state, error_message = nil)
update_attributes!({state: state.to_s,
state_updated_at: Time.now,
last_error: error_message},
without_protection: true)
end
end