Module: ActiveManageable::Methods::Update

Extended by:
ActiveSupport::Concern
Defined in:
lib/active_manageable/methods/update.rb

Instance Method Summary collapse

Instance Method Details

#update(id:, attributes:, options: {}) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/active_manageable/methods/update.rb', line 10

def update(id:, attributes:, options: {})
  initialize_state(attributes: attributes, options: options)

  @target = action_scope
  includes(@options[:includes])

  @target = find_object_for_update(id: id)
  authorize(record: @target)

  assign_attributes_for_update

  model_class.transaction do
    yield if block_given?
    update_object
  rescue ActiveRecord::RecordInvalid
    false
  end
end