Module: Haml2Erb::Mixins::CoMerging
- Defined in:
- lib/haml2erb/mixins/comerging.rb
Instance Method Summary collapse
- #comerge ⇒ Object
-
#comerge!(hash_b) ⇒ Object
inclusive merge that combines results of two hashes when merging.
Instance Method Details
#comerge ⇒ Object
4 5 6 7 |
# File 'lib/haml2erb/mixins/comerging.rb', line 4 def comerge # NOT IMPLEMENTED YET fail "comerge command not implemented yet" end |
#comerge!(hash_b) ⇒ Object
inclusive merge that combines results of two hashes when merging
10 11 12 13 14 15 16 17 18 19 |
# File 'lib/haml2erb/mixins/comerging.rb', line 10 def comerge! hash_b hash_a = self hash_b.respond_to?(:each_pair) && hash_b.each_pair do |k,v| hash_a[k] = hash_a[k] ? (hash_a[k].respond_to?(:push) ? hash_a[k].push(v) : [ hash_a[k], v ]) : v end end |