module RSpec::Core::HashImitatable

def self.included(klass)

def self.included(klass)
  klass.extend ClassMethods
end

def [](key)

def [](key)
  issue_deprecation(:[], key)
  if directly_supports_attribute?(key)
    get_value(key)
  else
    extra_hash_attributes[key]
  end
end

def []=(key, value)

def []=(key, value)
  issue_deprecation(:[]=, key, value)
  if directly_supports_attribute?(key)
    set_value(key, value)
  else
    extra_hash_attributes[key] = value
  end
end

def directly_supports_attribute?(name)

def directly_supports_attribute?(name)
  self.class.hash_attribute_names.include?(name)
end

def extra_hash_attributes

def extra_hash_attributes
  @extra_hash_attributes ||= {}
end

def get_value(name)

def get_value(name)
  __send__(name)
end

def hash_for_delegation

def hash_for_delegation
  to_h
end

def issue_deprecation(_method_name, *_args)

def issue_deprecation(_method_name, *_args)
  # no-op by default: subclasses can override
end

def set_value(name, value)

def set_value(name, value)
  __send__(:"#{name}=", value)
end

def to_h

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