Method: AstroPay::Model#attributes=

Defined in:
lib/astro_pay/model.rb

#attributes=(attributes = {}) ⇒ Object

Note:

If raised, [NoMethodError] will be caught and a message will be printed to the standard output.

Sets a given hash values as attribute values for the class. It will try to match the keys of the hash to existent attributes that have accessors.

Parameters:

  • attributes (Hash) (defaults to: {})


23
24
25
26
27
28
29
30
31
# File 'lib/astro_pay/model.rb', line 23

def attributes=(attributes = {})
  attributes.each do |name, value|
    begin
      send("#{name.to_s.underscore}=", value)
    rescue NoMethodError => e
      puts "Unable to assign #{name.to_s.underscore} with value #{value}. No such method."
    end
  end
end