Class: Toast::SingularAssocRequest
- Inherits:
-
Object
- Object
- Toast::SingularAssocRequest
- Includes:
- Errors, RequestHelpers
- Defined in:
- lib/toast/singular_assoc_request.rb
Instance Method Summary collapse
-
#initialize(id, config, base_config, auth, request) ⇒ SingularAssocRequest
constructor
A new instance of SingularAssocRequest.
- #respond ⇒ Object
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) ⇒ SingularAssocRequest
Returns a new instance of SingularAssocRequest.
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/toast/singular_assoc_request.rb', line 8 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
#respond ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'lib/toast/singular_assoc_request.rb', line 20 def respond if @verb.in? %w(get link unlink) self.send(@verb) else response :method_not_allowed, headers: {'Allow' => allowed_methods(@config)}, msg: "#{@verb.upcase} not supported for singular association requests" end end |