Class: Mapping
Overview
TODO I’m not sure I like this approach? - maybe just a hash would be clearer
Instance Attribute Summary collapse
-
#hash ⇒ Object
readonly
Returns the value of attribute hash.
Instance Method Summary collapse
-
#initialize(hash = {}) ⇒ Mapping
constructor
A new instance of Mapping.
- #merge(mapping) ⇒ Object
-
#method_missing(sym, *args, &block) ⇒ Object
TODO Come back to this and include responds_to etc stackoverflow.com/questions/291132/method-missing-gotchas-in-ruby.
- #values ⇒ Object
Constructor Details
#initialize(hash = {}) ⇒ Mapping
Returns a new instance of Mapping.
6 7 8 9 |
# File 'lib/Mapping.rb', line 6 def initialize(hash={}) super() @hash = hash end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &block) ⇒ Object
TODO Come back to this and include responds_to etc stackoverflow.com/questions/291132/method-missing-gotchas-in-ruby
21 22 23 24 |
# File 'lib/Mapping.rb', line 21 def method_missing(sym, *args, &block) return @hash.send(sym, *args, &block) if @hash.respond_to?(sym) super(sym, *args, &block) end |
Instance Attribute Details
#hash ⇒ Object (readonly)
Returns the value of attribute hash.
4 5 6 |
# File 'lib/Mapping.rb', line 4 def hash @hash end |