Module: OpenHash
- Defined in:
- lib/pipeline_toolkit/open_hash.rb
Overview
Stolen from
http://github.com/karottenreibe/ohash/
Instance Method Summary collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args) ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/pipeline_toolkit/open_hash.rb', line 4 def method_missing(meth, *args) method = meth.to_s if method =~ %r{.+=$} super unless args.length == 1 self[method[0...-1].to_sym] = args.first else self[meth] end end |
Instance Method Details
#select_keys(*keys) ⇒ Object
15 16 17 18 19 20 |
# File 'lib/pipeline_toolkit/open_hash.rb', line 15 def select_keys(*keys) h = {} self.each do |key, value| h[key] = value if keys.include?(key) end end |