extractable_options?

extractable_options?() Instance Public methods By default, only instances of Hash itself are extractable. Subclasses of Hash may implement this method and return true to declare themselves as extractable. If a Hash is extractable, Array#extract_options! pops it from the Array when it is the last element of the Array.

nested_under_indifferent_access

nested_under_indifferent_access() Instance Public methods Called when object is nested under an object that receives with_indifferent_access. This method will be called on the current object by the enclosing object and is aliased to with_indifferent_access by default. Subclasses of Hash may overwrite this method to return self if converting to an ActiveSupport::HashWithIndifferentAccess would not be desirable. b = { b: 1 } { a: b }.with_indifferent_access['a'] # calls b.nested_unde

reverse_merge

reverse_merge(other_hash) Instance Public methods Merges the caller into other_hash. For example, options = options.reverse_merge(size: 25, velocity: 10) is equivalent to options = { size: 25, velocity: 10 }.merge(options) This is particularly useful for initializing an options hash with default values.

reverse_merge!

reverse_merge!(other_hash) Instance Public methods Destructive reverse_merge. reverse_update

reverse_update

reverse_update(other_hash) Instance Public methods Alias for: reverse_merge!

slice

slice(*keys) Instance Public methods Slice a hash to include only the given keys. This is useful for limiting an options hash to valid keys before passing to a method: def search(criteria = {}) criteria.assert_valid_keys(:mass, :velocity, :time) end search(options.slice(:mass, :velocity, :time)) If you have an array of keys you want to limit to, you should splat them: valid_keys = [:mass, :velocity, :time] search(options.slice(*valid_keys))

slice!

slice!(*keys) Instance Public methods Replaces the hash with only the given keys. Returns a hash containing the removed key/value pairs. { a: 1, b: 2, c: 3, d: 4 }.slice!(:a, :b) # => {:c=>3, :d=>4}

stringify_keys

stringify_keys() Instance Public methods Returns a new hash with all keys converted to strings. hash = { name: 'Rob', age: '28' } hash.stringify_keys # => { "name" => "Rob", "age" => "28" }

stringify_keys!

stringify_keys!() Instance Public methods Destructively convert all keys to strings. Same as stringify_keys, but modifies self.

symbolize_keys

symbolize_keys() Instance Public methods Returns a new hash with all keys converted to symbols, as long as they respond to to_sym. hash = { 'name' => 'Rob', 'age' => '28' } hash.symbolize_keys # => { name: "Rob", age: "28" } to_options