Module: Kraut::Mapper
Overview
Kraut::Mapper
Contains methods for mapping attributes.
Instance Method Summary collapse
-
#initialize(attributes = nil) ⇒ Object
Accepts a Hash of
attributes
and assigns them via writer methods. -
#mass_assign!(attributes) ⇒ Object
Expects a Hash of
attributes
and assigns them via attribute writers.
Instance Method Details
#initialize(attributes = nil) ⇒ Object
Accepts a Hash of attributes
and assigns them via writer methods. Calls an after_initialize
method if available.
10 11 12 |
# File 'lib/kraut/mapper.rb', line 10 def initialize(attributes = nil) mass_assign! attributes end |
#mass_assign!(attributes) ⇒ Object
Expects a Hash of attributes
and assigns them via attribute writers.
15 16 17 |
# File 'lib/kraut/mapper.rb', line 15 def mass_assign!(attributes) attributes.each { |key, value| send "#{key}=", value } if attributes end |