Exception: SmartParams::Error::InvalidPropertyType

Inherits:
SmartParams::Error show all
Defined in:
lib/smart_params/error/invalid_property_type.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(keychain:, wanted:, raw:) ⇒ InvalidPropertyType

Returns a new instance of InvalidPropertyType.



8
9
10
11
12
# File 'lib/smart_params/error/invalid_property_type.rb', line 8

def initialize(keychain:, wanted:, raw:)
  @keychain = keychain
  @wanted = wanted
  @raw = raw
end

Instance Attribute Details

#keychainObject (readonly)

Returns the value of attribute keychain.



4
5
6
# File 'lib/smart_params/error/invalid_property_type.rb', line 4

def keychain
  @keychain
end

#rawObject (readonly)

Returns the value of attribute raw.



6
7
8
# File 'lib/smart_params/error/invalid_property_type.rb', line 6

def raw
  @raw
end

#wantedObject (readonly)

Returns the value of attribute wanted.



5
6
7
# File 'lib/smart_params/error/invalid_property_type.rb', line 5

def wanted
  @wanted
end

Instance Method Details

#as_jsonObject



18
19
20
21
22
23
24
# File 'lib/smart_params/error/invalid_property_type.rb', line 18

def as_json
  {
    "keychain" => keychain,
    "wanted" => wanted.name,
    "raw" => raw
  }
end

#messageObject



14
15
16
# File 'lib/smart_params/error/invalid_property_type.rb', line 14

def message
  "expected #{keychain.inspect} to be #{wanted.name}, but was #{raw.inspect}"
end