Class: ActiveSupport::InheritableOptions
  
  
  
Overview
  
    
Inheritable Options
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 h.boy  
If the existing hash has string keys, call Hash#symbolize_keys on it.
h = ActiveSupport::InheritableOptions.new({ 'girl' => 'Mary', 'boy' => 'John' }.symbolize_keys)
h.girl h.boy  
   
 
  
  
    
      Instance Method Summary
      collapse
    
    
  
  
  
  
  
  
  
  
  
  
  #[], #[]=, #dig, #extractable_options?, #method_missing, #respond_to_missing?
  
  
  
  
  
  
  
  
  Methods inherited from Hash
  #as_json, #assert_valid_keys, #compact_blank, #compact_blank!, #deep_dup, #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!, #extract!, #extractable_options?, from_trusted_xml, from_xml, #present?, #reverse_merge, #reverse_merge!, #slice!, #stringify_keys, #stringify_keys!, #symbolize_keys, #symbolize_keys!, #to_query, #to_xml, #with_indifferent_access
  
  
  
  
  
  
  
  
  
  #deep_merge, #deep_merge!, #deep_merge?
  Constructor Details
  
    
  
  
    
Returns a new instance of InheritableOptions.
   
 
  
  
    
      
90
91
92
93
94
95
96
97
98
99
100
101 
     | 
    
      # File 'lib/active_support/ordered_options.rb', line 90
def initialize(parent = nil)
  @parent = parent
  if @parent.kind_of?(OrderedOptions)
        super() { |h, k| @parent._get(k) }
  elsif @parent
    super() { |h, k| @parent[k] }
  else
    super()
    @parent = {}
  end
end
     | 
  
 
  
 
  
    Instance Method Details
    
      
  
  
    #==(other)  ⇒ Object 
  
  
  
  
    
      
107
108
109 
     | 
    
      # File 'lib/active_support/ordered_options.rb', line 107
def ==(other)
  to_h == other.to_h
end 
     | 
  
 
    
      
  
  
    #each(&block)  ⇒ Object 
  
  
  
  
    
      
142
143
144
145 
     | 
    
      # File 'lib/active_support/ordered_options.rb', line 142
def each(&block)
  to_h.each(&block)
  self
end 
     | 
  
 
    
      
  
  
    #inheritable_copy  ⇒ Object 
  
  
  
  
    
      
134
135
136 
     | 
    
      # File 'lib/active_support/ordered_options.rb', line 134
def inheritable_copy
  self.class.new(self)
end 
     | 
  
 
    
      
  
  
    
      
111
112
113 
     | 
    
      # File 'lib/active_support/ordered_options.rb', line 111
def inspect
  "#<#{self.class.name} #{to_h.inspect}>"
end
     | 
  
 
    
      
  
  
    #key?(key)  ⇒ Boolean 
  
  
  
  
    
      
126
127
128 
     | 
    
      # File 'lib/active_support/ordered_options.rb', line 126
def key?(key)
  super || @parent.key?(key)
end 
     | 
  
 
    
      
  
  
    #overridden?(key)  ⇒ Boolean 
  
  
  
  
    
      
130
131
132 
     | 
    
      # File 'lib/active_support/ordered_options.rb', line 130
def overridden?(key)
  !!(@parent && @parent.key?(key) && own_key?(key.to_sym))
end 
     | 
  
 
    
      
  
  
    #pretty_print(pp)  ⇒ Object 
  
  
  
  
    
      
119
120
121 
     | 
    
      # File 'lib/active_support/ordered_options.rb', line 119
def pretty_print(pp)
  pp.pp_hash(to_h)
end 
     | 
  
 
    
      
  
  
    
      
138
139
140 
     | 
    
      # File 'lib/active_support/ordered_options.rb', line 138
def to_a
  entries
end 
     | 
  
 
    
      
  
  
    
      
103
104
105 
     | 
    
      # File 'lib/active_support/ordered_options.rb', line 103
def to_h
  @parent.merge(self)
end 
     | 
  
 
    
      
  
  
    
      
115
116
117 
     | 
    
      # File 'lib/active_support/ordered_options.rb', line 115
def to_s
  to_h.to_s
end 
     |