Module: MethodHashMethods
- Included in:
 - Connect::ObjectDefinition, Connect::ObjectRepresentation, MethodHash
 
- Defined in:
 - lib/method_hash.rb
 
Overview
This modules allows you to access the elements of a hash with a method like syntax
Instance Method Summary collapse
- 
  
    
      #[](index)  ⇒ Any 
    
    
  
  
  
  
  
  
  
  
  
    
extracts a entry from the hash.
 - 
  
    
      #method_missing(method_sym, *_arguments, &_block)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Implements the lookup of hash entries based on the method call.
 
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_sym, *_arguments, &_block) ⇒ Object
Implements the lookup of hash entries based on the method call
      9 10 11 12 13 14 15 16  | 
    
      # File 'lib/method_hash.rb', line 9 def method_missing(method_sym, *_arguments, &_block) key = method_sym.to_s if self.key?(key) self[key] else fail ArgumentError, "requested unassigned attribute #{key} from #{self}" end end  | 
  
Instance Method Details
#[](index) ⇒ Any
extracts a entry from the hash
      25 26 27 28  | 
    
      # File 'lib/method_hash.rb', line 25 def [](index) fail "#{index} not found" unless self.key?(index) super end  |