class Adapter::ActiveModel::CommonHelpers::ObjectHash
Attributes
existing[RW]
existing denotes whether we search for attributes that exist on the resource or attributes that shouldn't exist
hash[RW]
existing denotes whether we search for attributes that exist on the resource or attributes that shouldn't exist
Public Class Methods
new(hash, existing: true)
click to toggle source
# File lib/rspec/api_helpers/adapter/active_model/common_helpers.rb, line 30 def initialize(hash, existing: true) @hash = HashWithIndifferentAccess.new(hash) @existing = existing end
Public Instance Methods
method_missing(name)
click to toggle source
# File lib/rspec/api_helpers/adapter/active_model/common_helpers.rb, line 35 def method_missing(name) if existing if hash.key?(name) return hash[name] else return raise KeyError.new("Attribute not found in resource: #{name}") end else if hash.key?(name) return raise( KeyError.new( "Attribute found in resource when it shouldn't: #{name}" ) ) else return :attribute_not_found end end end