class Turnout::InheritableOptions

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) click to toggle source
Calls superclass method Turnout::OrderedOptions::new
# File lib/turnout/ordered_options.rb, line 83
def initialize(parent = nil)
  if parent.kind_of?(Turnout::OrderedOptions)
    # use the faster _get when dealing with OrderedOptions
    super(parent) {|key,value| parent._get(key) }
  elsif parent
    super(parent) { |key, value| parent[key] }
  else
    super(parent)
  end
end

Public Instance Methods

inheritable_copy() click to toggle source
# File lib/turnout/ordered_options.rb, line 94
def inheritable_copy
  self.class.new(self)
end