Class: Isolator::SimpleHashie
- Inherits:
-
Hash
- Object
- Hash
- Isolator::SimpleHashie
- Defined in:
- lib/isolator/simple_hashie.rb
Overview
Hash with key accessors
Instance Method Summary collapse
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(key, *args, &block) ⇒ Object
6 7 8 9 10 11 12 13 14 |
# File 'lib/isolator/simple_hashie.rb', line 6 def method_missing(key, *args, &block) key_str = key.to_s if key_str.end_with?("=") self[key_str.tr("=")] = args.first else fetch(key_str) { super } end end |
Instance Method Details
#respond_to_missing?(key) ⇒ Boolean
16 17 18 19 20 21 22 23 |
# File 'lib/isolator/simple_hashie.rb', line 16 def respond_to_missing?(key) key_str = key.to_s if key_str.end_with?("=") key?(key_str.tr("=")) || super else key?(key_str) || super end end |