класс ActiveSupport::InheritableOptions
InheritableOptions предоставляет конструктор для создания OrderedOptions хеша, унаследованного от другого хеша.
Используйте этот класс, если у вас уже есть хеш, и вы хотите создать новый на его основе.
h = ActiveSupport::InheritableOptions.new({ girl: 'Mary', boy: 'John' })
h.girl # => 'Mary'
h.boy # => 'John'
Общедоступные методы класса
# 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 Вызывает метод суперкласса
Общедоступные методы экземпляра
# File activesupport/lib/active_support/ordered_options.rb, line 91 def inheritable_copy self.class.new(self) end
© 2004–2020 David Heinemeier Hansson
Licensed under the MIT License.