Mixin that makes the including class imitate a hash for backwards compatibility. The including class should use `attr_accessor` to declare attributes. @private
# File lib/rspec/core/metadata.rb, line 351 def self.included(klass) klass.extend ClassMethods end
# File lib/rspec/core/metadata.rb, line 389 def [](key) issue_deprecation(:[], key) if directly_supports_attribute?(key) get_value(key) else extra_hash_attributes[key] end end
# File lib/rspec/core/metadata.rb, line 399 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 lib/rspec/core/metadata.rb, line 355 def to_h hash = extra_hash_attributes.dup self.class.hash_attribute_names.each do |name| hash[name] = __send__(name) end hash end
# File lib/rspec/core/metadata.rb, line 415 def directly_supports_attribute?(name) self.class.hash_attribute_names.include?(name) end
# File lib/rspec/core/metadata.rb, line 411 def extra_hash_attributes @extra_hash_attributes ||= {} end
# File lib/rspec/core/metadata.rb, line 419 def get_value(name) __send__(name) end
# File lib/rspec/core/metadata.rb, line 427 def hash_for_delegation to_h end
# File lib/rspec/core/metadata.rb, line 431 def issue_deprecation(_method_name, *_args) # no-op by default: subclasses can override end
# File lib/rspec/core/metadata.rb, line 423 def set_value(name, value) __send__(:"#{name}=", value) end