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.
119 120 121 122 123 124 125 126 127 128 129 |
# File 'lib/flow_chat/async_job.rb', line 119 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.
117 118 119 |
# File 'lib/flow_chat/async_job.rb', line 117 def headers @headers end |
#host ⇒ Object (readonly)
Returns the value of attribute host.
117 118 119 |
# File 'lib/flow_chat/async_job.rb', line 117 def host @host end |
#method ⇒ Object (readonly)
Returns the value of attribute method.
117 118 119 |
# File 'lib/flow_chat/async_job.rb', line 117 def method @method end |
#params ⇒ Object (readonly)
Returns the value of attribute params.
117 118 119 |
# File 'lib/flow_chat/async_job.rb', line 117 def params @params end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
117 118 119 |
# File 'lib/flow_chat/async_job.rb', line 117 def path @path end |
#remote_ip ⇒ Object (readonly)
Returns the value of attribute remote_ip.
117 118 119 |
# File 'lib/flow_chat/async_job.rb', line 117 def remote_ip @remote_ip end |
Instance Method Details
#body ⇒ Object
157 158 159 160 |
# File 'lib/flow_chat/async_job.rb', line 157 def body # Return StringIO-like object if body content exists @body_content ? BackgroundRequestBody.new(@body_content) : nil end |
#cookies ⇒ Object
162 163 164 165 |
# File 'lib/flow_chat/async_job.rb', line 162 def # Background jobs don't have cookies {} end |
#get? ⇒ Boolean
149 150 151 |
# File 'lib/flow_chat/async_job.rb', line 149 def get? method.upcase == "GET" end |
#head? ⇒ Boolean
153 154 155 |
# File 'lib/flow_chat/async_job.rb', line 153 def head? method.upcase == "HEAD" end |
#post? ⇒ Boolean
145 146 147 |
# File 'lib/flow_chat/async_job.rb', line 145 def post? method.upcase == "POST" end |
#request_method ⇒ Object
Rails request interface compatibility
132 133 134 |
# File 'lib/flow_chat/async_job.rb', line 132 def request_method method.upcase end |
#ssl? ⇒ Boolean
140 141 142 143 |
# File 'lib/flow_chat/async_job.rb', line 140 def ssl? # Background jobs don't have SSL context false end |
#user_agent ⇒ Object
136 137 138 |
# File 'lib/flow_chat/async_job.rb', line 136 def user_agent @headers["User-Agent"] end |