Class: JSONAPIHelpers::ActionDispatchRequestWrapper

Inherits:
Delegator
  • Object
show all
Defined in:
lib/jsonapi_helpers/action_dispatch_request_wrapper.rb

Overview

NOTE:

For some weird reason, ActiveModelSerializers call #original_url on
ActionDispatch::Request, which isn't defined. In order to avoid monkey matching,
this wrapper object delegates all methods to the request object and only adds one
method #request_url

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(request) ⇒ ActionDispatchRequestWrapper

Returns a new instance of ActionDispatchRequestWrapper.



12
13
14
15
# File 'lib/jsonapi_helpers/action_dispatch_request_wrapper.rb', line 12

def initialize(request)
  super
  @action_dispatch_request = request
end

Instance Attribute Details

#action_dispatch_requestObject (readonly)

Returns the value of attribute action_dispatch_request.



10
11
12
# File 'lib/jsonapi_helpers/action_dispatch_request_wrapper.rb', line 10

def action_dispatch_request
  @action_dispatch_request
end

Instance Method Details

#__getobj__Object



17
18
19
# File 'lib/jsonapi_helpers/action_dispatch_request_wrapper.rb', line 17

def __getobj__
  @action_dispatch_request
end

#__setobj__(request) ⇒ Object



21
22
23
# File 'lib/jsonapi_helpers/action_dispatch_request_wrapper.rb', line 21

def __setobj__(request)
  @action_dispatch_request = request
end

#request_urlObject



25
26
27
# File 'lib/jsonapi_helpers/action_dispatch_request_wrapper.rb', line 25

def request_url
  "#{@action_dispatch_request.base_url}#{@action_dispatch_request.path}"
end