Module: RestMyCase::Status

Included in:
HttpStatus
Defined in:
lib/rest_my_case/status.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(parent_class) ⇒ Object



12
13
14
# File 'lib/rest_my_case/status.rb', line 12

def self.included(parent_class)
  parent_class.extend ClassMethods
end

Instance Method Details

#failure(status, error = nil) ⇒ Object



20
21
22
23
24
25
26
# File 'lib/rest_my_case/status.rb', line 20

def failure(status, error = nil)
  error = { message: error } unless error.is_a?(Hash)

  error[:status] = status

  error(error)
end

#failure!(status, error = nil) ⇒ Object



28
29
30
# File 'lib/rest_my_case/status.rb', line 28

def failure!(status, error = nil)
  failure(status, error) && fail(Errors::Abort)
end

#statusObject



16
17
18
# File 'lib/rest_my_case/status.rb', line 16

def status
  context.status
end