Class: ActiveSupport::InheritableOptions
- Inherits:
 - 
      OrderedOptions
      
        
- Object
 - Hash
 - OrderedOptions
 - ActiveSupport::InheritableOptions
 
 
- Defined in:
 - lib/active_support/ordered_options.rb
 
Overview
InheritableOptions provides a constructor to build an OrderedOptions hash inherited from another hash.
Use this if you already have some hash and you want to create a new one based on it.
h = ActiveSupport::InheritableOptions.new({ girl: 'Mary', boy: 'John' })
h.girl # => 'Mary'
h.boy  # => 'John'
  Direct Known Subclasses
Instance Method Summary collapse
- #inheritable_copy ⇒ Object
 - 
  
    
      #initialize(parent = nil)  ⇒ InheritableOptions 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    
A new instance of InheritableOptions.
 
Methods inherited from OrderedOptions
#[], #[]=, #extractable_options?, #inspect, #method_missing, #respond_to_missing?
Methods inherited from Hash
#as_json, #assert_valid_keys, #compact_blank, #compact_blank!, #deep_dup, #deep_merge, #deep_merge!, #deep_stringify_keys, #deep_stringify_keys!, #deep_symbolize_keys, #deep_symbolize_keys!, #deep_transform_keys, #deep_transform_keys!, #deep_transform_values, #deep_transform_values!, #except, #except!, #extract!, #extractable_options?, from_trusted_xml, from_xml, #reverse_merge, #reverse_merge!, #slice!, #stringify_keys, #stringify_keys!, #symbolize_keys, #symbolize_keys!, #to_query, #to_xml, #with_indifferent_access
Constructor Details
#initialize(parent = nil) ⇒ InheritableOptions
Returns a new instance of InheritableOptions.
      80 81 82 83 84 85 86 87 88 89  | 
    
      # File 'lib/active_support/ordered_options.rb', line 80 def initialize(parent = nil) if parent.kind_of?(OrderedOptions) # use the faster _get when dealing with OrderedOptions super() { |h, k| parent._get(k) } elsif parent super() { |h, k| parent[k] } else super() end end  | 
  
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class ActiveSupport::OrderedOptions
Instance Method Details
#inheritable_copy ⇒ Object
      91 92 93  | 
    
      # File 'lib/active_support/ordered_options.rb', line 91 def inheritable_copy self.class.new(self) end  |