Module: ApiModel::Assignment

Included in:
Base, Initializer
Defined in:
lib/api_model/assignment.rb

Instance Method Summary collapse

Instance Method Details

#update_attributes(values = {}) ⇒ Object

Convenience method to change attributes on an instance en-masse using a hash. This is useful for when an api response includes changed attributes and you want to update the current instance with the changes.



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/api_model/assignment.rb', line 7

def update_attributes(values={})
  return unless values.present?

  values.each do |key,value|
    begin
      public_send "#{key}=", value
    rescue
      Log.debug "Could not set #{key} on #{self.class.name}"
    end
  end
end