Spec-Zone.ru › Ruby on Rails 6.1

класс ActiveSupport::OrderedHash

Родитель:
Hash

УСТАРЕВШЕЕ: ActiveSupport::OrderedHash реализует хеш, сохраняющий порядок вставки.

oh = ActiveSupport::OrderedHash.new
oh[:a] = 1
oh[:b] = 2
oh.keys # => [:a, :b], this order is guaranteed

Также, отображает функцию omap для файлов YAML (см. yaml.org/type/omap.html) для поддержки упорядоченных элементов при загрузке из YAML.

ActiveSupport::OrderedHash имеет пространство имён, чтобы предотвратить конфликты с другими реализациями.

Открытые методы экземпляров

encode_with(coder) Показать исходный код
# File activesupport/lib/active_support/ordered_hash.rb, line 29
def encode_with(coder)
  coder.represent_seq "!omap", map { |k, v| { k => v } }
end
extractable_options?() Показать исходный код
# File activesupport/lib/active_support/ordered_hash.rb, line 46
def extractable_options?
  true
end

Возвращает true, чтобы убедиться, что этот хеш можно извлечь с помощью Array#extract_options!

nested_under_indifferent_access() Показать исходный код
# File activesupport/lib/active_support/ordered_hash.rb, line 41
def nested_under_indifferent_access
  self
end
reject(*args, &block) Показать исходный код
# File activesupport/lib/active_support/ordered_hash.rb, line 37
def reject(*args, &block)
  dup.tap { |hash| hash.reject!(*args, &block) }
end
select(*args, &block) Показать исходный код
# File activesupport/lib/active_support/ordered_hash.rb, line 33
def select(*args, &block)
  dup.tap { |hash| hash.select!(*args, &block) }
end
to_yaml_type() Показать исходный код
# File activesupport/lib/active_support/ordered_hash.rb, line 25
def to_yaml_type
  "!tag:yaml.org,2002:omap"
end

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

Spec-Zone.ru

Настройки Оффлайн Что нового Помощь О нас
Spec-Zone .ru
спецификации, руководства, описания, API