Class: HashMap::Mapper
- Inherits:
-
Object
- Object
- HashMap::Mapper
- Defined in:
- lib/hash_map/mapper.rb
Instance Attribute Summary collapse
-
#hash_map ⇒ Object
readonly
Returns the value of attribute hash_map.
-
#original ⇒ Object
readonly
Returns the value of attribute original.
Instance Method Summary collapse
-
#initialize(original, hash_map) ⇒ Mapper
constructor
A new instance of Mapper.
- #output ⇒ Object
Constructor Details
#initialize(original, hash_map) ⇒ Mapper
Returns a new instance of Mapper.
4 5 6 7 |
# File 'lib/hash_map/mapper.rb', line 4 def initialize(original, hash_map) @original = Fusu::HashWithIndifferentAccess.new(original) @hash_map = hash_map end |
Instance Attribute Details
#hash_map ⇒ Object (readonly)
Returns the value of attribute hash_map.
3 4 5 |
# File 'lib/hash_map/mapper.rb', line 3 def hash_map @hash_map end |
#original ⇒ Object (readonly)
Returns the value of attribute original.
3 4 5 |
# File 'lib/hash_map/mapper.rb', line 3 def original @original end |
Instance Method Details
#output ⇒ Object
9 10 11 12 13 14 15 16 |
# File 'lib/hash_map/mapper.rb', line 9 def output new_hash = Fusu::HashWithIndifferentAccess.new hash_map.class.attributes.each do |struc| value = get_value(struc) Fusu::Hash.deep_merge!(new_hash, build_keys(struc[:key], value)) end new_hash end |