W3cubDocs

/Ruby on Rails 7.0

class ActiveSupport::InheritableOptions

Parent:
ActiveSupport::OrderedOptions

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'

Public Class Methods

new(parent = nil) Show source
# File activesupport/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
Calls superclass method

Public Instance Methods

inheritable_copy() Show source
# File activesupport/lib/active_support/ordered_options.rb, line 91
def inheritable_copy
  self.class.new(self)
end

© 2004–2021 David Heinemeier Hansson
Licensed under the MIT License.