Class: Azeroth::RequestHandler Private

Inherits:
Object
  • Object
show all
Defined in:
lib/azeroth/request_handler.rb,
lib/azeroth/request_handler/new.rb,
lib/azeroth/request_handler/edit.rb,
lib/azeroth/request_handler/show.rb,
lib/azeroth/request_handler/index.rb,
lib/azeroth/request_handler/create.rb,
lib/azeroth/request_handler/update.rb,
lib/azeroth/request_handler/destroy.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Handle a request on behalf of the controller

Request handler sends messages to the controller in order to get the resource and rendering the response

Direct Known Subclasses

Create, Destroy, Index, New, Show, Update

Defined Under Namespace

Classes: Create, Destroy, Edit, Index, New, Show, Update

Instance Method Summary collapse

Constructor Details

#initialize(controller, model, options) ⇒ RequestHandler

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of RequestHandler.

Parameters:



21
22
23
24
25
# File 'lib/azeroth/request_handler.rb', line 21

def initialize(controller, model, options)
  @controller = ControllerInterface.new(controller)
  @model = model
  @options = options
end

Instance Method Details

#processString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

process the request

No action is performd when format is HTML

When format is json, the resource is fetched/processed (by the subclass) and returned as json (decorated)

Returns:

  • (String)


35
36
37
38
39
40
41
42
43
# File 'lib/azeroth/request_handler.rb', line 35

def process
  return unless json?

  controller.add_headers(headers)
  controller.render_json(
    model.decorate(resource),
    status
  )
end