Class: MultiRedis::Data
- Inherits:
-
Hash
- Object
- Hash
- MultiRedis::Data
- Defined in:
- lib/multi_redis/data.rb
Instance Method Summary collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(symbol, *args, &block) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/multi_redis/data.rb', line 5 def method_missing symbol, *args, &block if args.empty? self[symbol] elsif args.length == 1 && m = symbol.to_s.match(/\A(.*)\=\Z/) acc = m[1].to_sym raise ArgumentError, "Cannot set property #{acc}, method ##{acc} already exists" if respond_to? acc self[acc] = args[0] else super symbol, *args, &block end end |