Exception: SimpleJsonapi::DuplicateResourceError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/simple_jsonapi/helpers/exceptions.rb

Overview

The error raised when the same resource is added to the included member twice.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(type, id, msg = nil) ⇒ DuplicateResourceError

Returns a new instance of DuplicateResourceError.

Parameters:

  • type (String)
  • id (String)
  • msg (String) (defaults to: nil)


13
14
15
16
17
# File 'lib/simple_jsonapi/helpers/exceptions.rb', line 13

def initialize(type, id, msg = nil)
  @type = type
  @id = id
  @msg = msg
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



8
9
10
# File 'lib/simple_jsonapi/helpers/exceptions.rb', line 8

def id
  @id
end

#typeObject (readonly)

Returns the value of attribute type.



8
9
10
# File 'lib/simple_jsonapi/helpers/exceptions.rb', line 8

def type
  @type
end

Instance Method Details

#to_sObject



19
20
21
# File 'lib/simple_jsonapi/helpers/exceptions.rb', line 19

def to_s
  @msg.present? ? @msg : "Resource with type #{type} and id #{id} is already included"
end