Exception: SmartParams::InvalidPropertyTypeException

Inherits:
StandardError
  • Object
show all
Defined in:
lib/smart_params/invalid_property_type_exception.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(path:, wanted:, raw:, grievance:) ⇒ InvalidPropertyTypeException

Returns a new instance of InvalidPropertyTypeException.



11
12
13
14
15
16
17
18
# File 'lib/smart_params/invalid_property_type_exception.rb', line 11

def initialize(path:, wanted:, raw:, grievance:)
  @path = path
  @wanted = wanted
  @raw = raw
  @type = raw.inspect
  @grievance = grievance
  super(message)
end

Instance Attribute Details

#grievanceObject (readonly)

Returns the value of attribute grievance.



9
10
11
# File 'lib/smart_params/invalid_property_type_exception.rb', line 9

def grievance
  @grievance
end

#pathObject (readonly)

Returns the value of attribute path.



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

def path
  @path
end

#rawObject (readonly)

Returns the value of attribute raw.



7
8
9
# File 'lib/smart_params/invalid_property_type_exception.rb', line 7

def raw
  @raw
end

#typeObject (readonly)

Returns the value of attribute type.



8
9
10
# File 'lib/smart_params/invalid_property_type_exception.rb', line 8

def type
  @type
end

#wantedObject (readonly)

Returns the value of attribute wanted.



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

def wanted
  @wanted
end

Instance Method Details

#as_jsonObject



24
25
26
27
28
29
30
31
# File 'lib/smart_params/invalid_property_type_exception.rb', line 24

def as_json
  {
    "path" => path,
    "wanted" => wanted,
    "grievance" => grievance,
    "raw" => raw
  }
end

#messageObject



20
21
22
# File 'lib/smart_params/invalid_property_type_exception.rb', line 20

def message
  "expected /#{path.join('/')} to be #{wanted.name}, but is #{type} and #{grievance}"
end