Module: Restfulness::Resources::Events

Included in:
Restfulness::Resource
Defined in:
lib/restfulness/resources/events.rb

Overview

Special events that can be used in replies. The idea here is to cover the basic messages that most applications will deal with in their resources.

Constant Summary collapse

SUCCESS_EVENTS =
[
  [200, :ok],
  [201, :created],
  [202, :accepted],
  [203, :non_authoritative],
  [203, :non_authoritative_information],
  [204, :no_content],
  [205, :reset_content]
]
EXCEPTION_EVENTS =

Event definitions go here. We only support a limited subset so that we don’t end up with loads of methods that are not used. If you’d like to see another, please send us a pull request!

[
  # 300 Events
  [304, :not_modified],

  # 400 Events
  [400, :bad_request],
  [401, :unauthorized],
  [402, :payment_required],
  [403, :forbidden],
  [404, :resource_not_found],
  [405, :method_not_allowed],
  [408, :request_timeout],
  [409, :conflict],
  [410, :gone],
  [422, :unprocessable_entity]
]

Instance Method Summary collapse

Instance Method Details

#error!(code, payload = "", opts = {}) ⇒ Object

Main error event handler

Raises:



40
41
42
# File 'lib/restfulness/resources/events.rb', line 40

def error!(code, payload = "", opts = {})
  raise HTTPException.new(code, payload, opts)
end