Class: FlowChat::BackgroundRequest
- Inherits:
-
Object
- Object
- FlowChat::BackgroundRequest
- Defined in:
- lib/flow_chat/async_job.rb
Overview
Request object for background jobs Reconstructed from serialized webhook request data
Instance Attribute Summary collapse
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#method ⇒ Object
readonly
Returns the value of attribute method.
-
#params ⇒ Object
readonly
Returns the value of attribute params.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#remote_ip ⇒ Object
readonly
Returns the value of attribute remote_ip.
Instance Method Summary collapse
- #body ⇒ Object
- #cookies ⇒ Object
- #get? ⇒ Boolean
- #head? ⇒ Boolean
-
#initialize(request_data) ⇒ BackgroundRequest
constructor
A new instance of BackgroundRequest.
- #post? ⇒ Boolean
-
#request_method ⇒ Object
Rails request interface compatibility.
- #ssl? ⇒ Boolean
- #user_agent ⇒ Object
Constructor Details
#initialize(request_data) ⇒ BackgroundRequest
Returns a new instance of BackgroundRequest.
109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/flow_chat/async_job.rb', line 109 def initialize(request_data) @params = (request_data[:params] || {}).with_indifferent_access @method = request_data[:method] || "POST" @headers = OpenStruct.new(request_data[:headers] || {}) @host = request_data[:host] @path = request_data[:path] @body_content = request_data[:body] @remote_ip = request_data[:remote_ip] FlowChat.logger.debug { "BackgroundRequest: Initialized with method=#{@method}, params keys=#{@params.keys.inspect}" } end |
Instance Attribute Details
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
107 108 109 |
# File 'lib/flow_chat/async_job.rb', line 107 def headers @headers end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
107 108 109 |
# File 'lib/flow_chat/async_job.rb', line 107 def host @host end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
107 108 109 |
# File 'lib/flow_chat/async_job.rb', line 107 def method @method end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
107 108 109 |
# File 'lib/flow_chat/async_job.rb', line 107 def params @params end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
107 108 109 |
# File 'lib/flow_chat/async_job.rb', line 107 def path @path end |
#remote_ip ⇒ Object (readonly)
Returns the value of attribute remote_ip.
107 108 109 |
# File 'lib/flow_chat/async_job.rb', line 107 def remote_ip @remote_ip end |
Instance Method Details
#body ⇒ Object
147 148 149 150 |
# File 'lib/flow_chat/async_job.rb', line 147 def body # Return StringIO-like object if body content exists @body_content ? BackgroundRequestBody.new(@body_content) : nil end |
#cookies ⇒ Object
152 153 154 155 |
# File 'lib/flow_chat/async_job.rb', line 152 def # Background jobs don't have cookies {} end |
#get? ⇒ Boolean
139 140 141 |
# File 'lib/flow_chat/async_job.rb', line 139 def get? method.upcase == "GET" end |
#head? ⇒ Boolean
143 144 145 |
# File 'lib/flow_chat/async_job.rb', line 143 def head? method.upcase == "HEAD" end |
#post? ⇒ Boolean
135 136 137 |
# File 'lib/flow_chat/async_job.rb', line 135 def post? method.upcase == "POST" end |
#request_method ⇒ Object
Rails request interface compatibility
122 123 124 |
# File 'lib/flow_chat/async_job.rb', line 122 def request_method method.upcase end |
#ssl? ⇒ Boolean
130 131 132 133 |
# File 'lib/flow_chat/async_job.rb', line 130 def ssl? # Background jobs don't have SSL context false end |
#user_agent ⇒ Object
126 127 128 |
# File 'lib/flow_chat/async_job.rb', line 126 def user_agent @headers["User-Agent"] end |