Exception: Exceptions::Resource

Inherits:
Base
  • Object
show all
Defined in:
lib/exceptions/resource.rb

Instance Attribute Summary

Attributes inherited from Base

#object, #type

Instance Method Summary collapse

Methods inherited from Base

build, #initialize, #model?, #simple?

Constructor Details

This class inherits a constructor from Exceptions::Base

Instance Method Details

#errorString

for standard errors this method build a hash

Returns:

  • (String)

    json string



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/exceptions/resource.rb', line 4

def error
	{
		error: { 
			model: self.object["model"],
			attribute: self.object["attribute"],
			field: self.object["field"],
			message: self.object["message"],
			full_message: "#{self.object["attribute"]} #{self.object["message"]}"
		} 
	}
end

#messageString

return the error message

Returns:

  • (String)


18
19
20
# File 'lib/exceptions/resource.rb', line 18

def message
	self.error[:message]
end

#statusObject

return the error status



23
24
25
# File 'lib/exceptions/resource.rb', line 23

def status
	406
end