Module: RestMyCase::Status

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

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(parent_class) ⇒ Object



7
8
9
10
11
# File 'lib/rest_my_case/status.rb', line 7

def self.included(parent_class)
  return unless parent_class.respond_to? :trial_court

  parent_class.trial_court.context_class = Context::Status
end

Instance Method Details

#failure(status, error_message = nil) ⇒ Object



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

def failure(status, error_message = nil)
  if error_message.is_a?(Hash)
    error_data = error_message
  else
    error_data = { message: error_message }
  end

  error_data[:status] = status

  error(error_data)
end

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



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

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

#statusObject



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

def status
  context.status
end