Class: ActiveSupport::InheritableOptions
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Subclasses:
|
|
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
OrderedOptions,
::Hash
|
|
Instance Chain:
self,
OrderedOptions,
::Hash
|
|
Inherits: |
ActiveSupport::OrderedOptions
|
Defined in: | activesupport/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'
Class Method Summary
- .new(parent = nil) ⇒ InheritableOptions constructor
::Hash - Inherited
.from_trusted_xml | Builds a ::Hash from XML just like Hash.from_xml, but also allows ::Symbol and YAML. |
.from_xml | Returns a ::Hash containing a collection of pairs when the key is the node name and the value is its content. |
Instance Attribute Summary
::Hash - Inherited
#extractable_options? | By default, only instances of ::Hash itself are extractable. |
Instance Method Summary
OrderedOptions - Inherited
::Hash - Inherited
#assert_valid_keys | Validate all keys in a hash match |
#blank? | A hash is blank if it's empty: |
#compact | Returns a hash with non |
#compact! | Replaces current hash with non |
#deep_dup | Returns a deep copy of hash. |
#deep_merge | Returns a new hash with |
#deep_merge! | Same as |
#deep_stringify_keys | Returns a new hash with all keys converted to strings. |
#deep_stringify_keys! | Destructively convert all keys to strings. |
#deep_symbolize_keys | Returns a new hash with all keys converted to symbols, as long as they respond to |
#deep_symbolize_keys! | Destructively convert all keys to symbols, as long as they respond to |
#deep_transform_keys | Returns a new hash with all keys converted by the block operation. |
#deep_transform_keys! | Destructively convert all keys by using the block operation. |
#except | Returns a hash that includes everything but the given keys. |
#except! | Replaces the hash without the given keys. |
#extract! | Removes and returns the key/value pairs matching the given keys. |
#nested_under_indifferent_access | Alias for Hash#with_indifferent_access. |
#reverse_merge | Merges the caller into |
#reverse_merge! | Destructive |
#reverse_update | Alias for Hash#reverse_merge!. |
#slice | Slice a hash to include only the given keys. |
#slice! | Replaces the hash with only the given keys. |
#stringify_keys | Returns a new hash with all keys converted to strings. |
#stringify_keys! | Destructively convert all keys to strings. |
#symbolize_keys | Returns a new hash with all keys converted to symbols, as long as they respond to |
#symbolize_keys! | Destructively convert all keys to symbols, as long as they respond to |
#to_options | Alias for Hash#symbolize_keys. |
#to_options! | Alias for Hash#symbolize_keys!. |
#to_param | Alias for Hash#to_query. |
#to_query | Returns a string representation of the receiver suitable for use as a URL query string: |
#to_xml | Returns a string containing an XML representation of its receiver: |
#transform_keys | Returns a new hash with all keys converted using the block operation. |
#transform_keys! | Destructively convert all keys using the block operations. |
#transform_values | Returns a new hash with the results of running |
#transform_values! | Destructive |
#with_indifferent_access | Returns an HashWithIndifferentAccess out of its receiver: |
Constructor Details
.new(parent = nil) ⇒ InheritableOptions
# File 'activesupport/lib/active_support/ordered_options.rb', line 52
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
[ GitHub ]# File 'activesupport/lib/active_support/ordered_options.rb', line 63
def inheritable_copy self.class.new(self) end