Class: Domotics::Core::DataHashOperator
- Inherits:
- BasicObject
- Defined in:
- lib/domotics/core/data/data_hash.rb
Instance Method Summary collapse
-
#initialize(hash, key) ⇒ DataHashOperator
constructor
A new instance of DataHashOperator.
- #method_missing(symbol, *args) ⇒ Object
Constructor Details
#initialize(hash, key) ⇒ DataHashOperator
Returns a new instance of DataHashOperator.
23 24 25 |
# File 'lib/domotics/core/data/data_hash.rb', line 23 def initialize(hash, key) @hash, @key = hash, key end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(symbol, *args) ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'lib/domotics/core/data/data_hash.rb', line 27 def method_missing(symbol, *args) # Setter method [*=(value)] if symbol.to_s =~ /.*=\Z/ and args.size == 1 @hash.set "#{@key}:#{symbol.to_s[0..-2]}", args[0] elsif args.size == 0 @hash.get "#{@key}:#{symbol}" else nil end end |