module RSpec::Core::HashImitatable

Mixin that makes the including class imitate a hash for backwards compatibility. The including class should use ‘attr_accessor` to declare attributes. @private

Public Class Methods

# File rspec-core/lib/rspec/core/metadata.rb, line 350
def self.included(klass)
  klass.extend ClassMethods
end

Public Instance Methods

# File rspec-core/lib/rspec/core/metadata.rb, line 388
def [](key)
  issue_deprecation(:[], key)

  if directly_supports_attribute?(key)
    get_value(key)
  else
    extra_hash_attributes[key]
  end
end
# File rspec-core/lib/rspec/core/metadata.rb, line 398
def []=(key, value)
  issue_deprecation(:[]=, key, value)

  if directly_supports_attribute?(key)
    set_value(key, value)
  else
    extra_hash_attributes[key] = value
  end
end
# File rspec-core/lib/rspec/core/metadata.rb, line 354
def to_h
  hash = extra_hash_attributes.dup

  self.class.hash_attribute_names.each do |name|
    hash[name] = __send__(name)
  end

  hash
end