Class: InfinumJsonApiSetup::Error::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/infinum_json_api_setup/error.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(object: nil, message: nil) ⇒ Base

Returns a new instance of Base.

Parameters:

  • opts (Hash)


13
14
15
16
17
# File 'lib/infinum_json_api_setup/error.rb', line 13

def initialize(object: nil, message: nil)
  @details =
    details_from_object(object) || message || I18n.t("json_api.errors.#{http_status}.detail")
  @title = I18n.t("json_api.errors.#{http_status}.title")
end

Instance Attribute Details

#detailsString (readonly)

Returns:

  • (String)


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

def details
  @details
end

#titleString (readonly)

Returns:

  • (String)


8
9
10
# File 'lib/infinum_json_api_setup/error.rb', line 8

def title
  @title
end

Instance Method Details

#codeString

Returns:

  • (String)


20
21
22
# File 'lib/infinum_json_api_setup/error.rb', line 20

def code
  self.class.name.demodulize.underscore.upcase
end

#http_statusSymbol

Returns:

  • (Symbol)


25
26
27
# File 'lib/infinum_json_api_setup/error.rb', line 25

def http_status
  self.class.name.demodulize.underscore.to_sym
end