Module: HashMapper
- Defined in:
- lib/hash_mapper.rb
Defined Under Namespace
Constant Summary collapse
- VERSION =
'0.0.4'
Instance Method Summary collapse
- #denormalize(a_hash) ⇒ Object
- #from(path, &filter) ⇒ Object (also: #to)
- #map(from, to, using = nil, &filter) ⇒ Object
- #maps ⇒ Object
- #normalize(a_hash) ⇒ Object
- #using(mapper_class) ⇒ Object
Instance Method Details
#denormalize(a_hash) ⇒ Object
41 42 43 |
# File 'lib/hash_mapper.rb', line 41 def denormalize(a_hash) perform_hash_mapping a_hash, :denormalize end |
#from(path, &filter) ⇒ Object Also known as: to
25 26 27 28 29 |
# File 'lib/hash_mapper.rb', line 25 def from(path, &filter) path_map = PathMap.new(path) path_map.filter = filter if block_given? # Useful if two blocks given path_map end |
#map(from, to, using = nil, &filter) ⇒ Object
20 21 22 23 |
# File 'lib/hash_mapper.rb', line 20 def map(from, to, using=nil, &filter) self.maps << Map.new(from, to, using) to.filter = filter if block_given? # Useful if just one block given end |
#maps ⇒ Object
16 17 18 |
# File 'lib/hash_mapper.rb', line 16 def maps @maps ||= [] end |
#normalize(a_hash) ⇒ Object
37 38 39 |
# File 'lib/hash_mapper.rb', line 37 def normalize(a_hash) perform_hash_mapping a_hash, :normalize end |
#using(mapper_class) ⇒ Object
33 34 35 |
# File 'lib/hash_mapper.rb', line 33 def using(mapper_class) mapper_class end |