Class: Toast::PluralAssocRequest

Inherits:
Object
  • Object
show all
Includes:
Errors, RequestHelpers
Defined in:
lib/toast/plural_assoc_request.rb

Instance Method Summary collapse

Methods included from RequestHelpers

#allowed_methods, #attr_selected?, #base_uri, #call_allow, #call_handler, #get_config, #is_active_record?, #represent, #represent_one, #response, #split_link_header

Constructor Details

#initialize(id, config, base_config, auth, request) ⇒ PluralAssocRequest

Returns a new instance of PluralAssocRequest.



9
10
11
12
13
14
15
16
17
18
19
# File 'lib/toast/plural_assoc_request.rb', line 9

def initialize  id, config, base_config, auth, request
  @id          = id
  @config      = config
  @base_config = base_config
  @selected_attributes = request.query_parameters[:toast_select].try(:split,/ *, */)
  @uri_params  = request.query_parameters
  @base_uri    = base_uri(request)
  @verb        = request.request_method.downcase
  @auth        = auth
  @request     = request
end

Instance Method Details

#respondObject



21
22
23
24
25
26
27
28
29
# File 'lib/toast/plural_assoc_request.rb', line 21

def respond
  if @verb.in? %w(get post link unlink)
    self.send(@verb)
  else
    response :method_not_allowed,
             headers: {'Allow' => allowed_methods(@config)},
             msg: "method #{@verb.upcase} not supported for association URIs"
  end
end