Class: FunctionalHash
- Inherits:
-
Hash
- Object
- Hash
- FunctionalHash
- Defined in:
- lib/includer.rb
Instance Method Summary collapse
- #become(mod) ⇒ Object
-
#initialize(hash = {}) ⇒ FunctionalHash
constructor
A new instance of FunctionalHash.
- #merge(hash) ⇒ Object
Constructor Details
#initialize(hash = {}) ⇒ FunctionalHash
Returns a new instance of FunctionalHash.
5 6 7 8 9 10 |
# File 'lib/includer.rb', line 5 def initialize(hash = {}) hash.each do | k, v | self[k] = v # Not important for this example end end |
Instance Method Details
#become(mod) ⇒ Object
17 18 19 20 21 |
# File 'lib/includer.rb', line 17 def become(mod) klass = Class.new(FunctionalHash) klass.send(:include, mod) klass.new(self) end |
#merge(hash) ⇒ Object
12 13 14 |
# File 'lib/includer.rb', line 12 def merge(hash) self.class.new(super(hash)) end |