Module: Granite::Action::AssignAttributes

Included in:
Granite::Action
Defined in:
lib/granite/action.rb

Overview

We are using a lot of stacked additional logic for ‘assign_attributes` At least, represented and nested attributes modules in ActiveData are having such a method redefiniions. Both are prepended to the Granite action, so we have to prepend our patch as well in order to put it above all other, so it will handle the attributes first.

Instance Method Summary collapse

Instance Method Details

#assign_attributes(attributes) ⇒ Object



32
33
34
35
36
37
# File 'lib/granite/action.rb', line 32

def assign_attributes(attributes)
  attributes = attributes.to_unsafe_hash if attributes.respond_to?(:to_unsafe_hash)
  attributes = attributes.stringify_keys
  attributes = attributes.merge(attributes.delete(model_name.param_key)) if attributes.key?(model_name.param_key)
  super(attributes)
end