Module: Encore::Entity::Input
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/encore/entity/input.rb,
lib/encore/entity/input/errors.rb,
lib/encore/entity/input/associations.rb,
lib/encore/entity/input/exposed_attributes.rb
Defined Under Namespace
Modules: Associations, ClassMethods, ExposedAttributes Classes: InvalidAttributeError
Instance Method Summary collapse
-
#assign_attributes(attributes = {}, opts = nil) ⇒ Object
Assign specific attribute to the object.
Instance Method Details
#assign_attributes(attributes = {}, opts = nil) ⇒ Object
Assign specific attribute to the object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/encore/entity/input.rb', line 24 def assign_attributes(attributes = {}, opts = nil) # Find the right context unless @context = opts.try(:delete, :context) @context = @object.persisted? ? :partial_update : :create end # Convert attribute keys to Attribute objects attributes = self.class.map_attributes(self.class, attributes) # Loop through every passed attribute and set it assign_provided_attributes(attributes) # If we're doing an update, for any exposed attribute that wasn't passed, set it to nil reset_forgotten_attributes(attributes) end |