Class: Magellan::Subscriber::Request
- Inherits:
-
Object
- Object
- Magellan::Subscriber::Request
- Defined in:
- lib/magellan/subscriber/request.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#env ⇒ Object
readonly
Returns the value of attribute env.
-
#headers ⇒ Object
readonly
Returns the value of attribute headers.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
-
#topic ⇒ Object
readonly
Returns the value of attribute topic.
Instance Method Summary collapse
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
6 7 8 |
# File 'lib/magellan/subscriber/request.rb', line 6 def body @body end |
#env ⇒ Object (readonly)
Returns the value of attribute env.
6 7 8 |
# File 'lib/magellan/subscriber/request.rb', line 6 def env @env end |
#headers ⇒ Object (readonly)
Returns the value of attribute headers.
6 7 8 |
# File 'lib/magellan/subscriber/request.rb', line 6 def headers @headers end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/magellan/subscriber/request.rb', line 6 def @options end |
#topic ⇒ Object (readonly)
Returns the value of attribute topic.
6 7 8 |
# File 'lib/magellan/subscriber/request.rb', line 6 def topic @topic end |
Instance Method Details
#option(key) ⇒ Object
8 9 10 |
# File 'lib/magellan/subscriber/request.rb', line 8 def option(key) [key] end |
#parse_message(request_message) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/magellan/subscriber/request.rb', line 12 def () @options = ['options'] @version = ["v"] || 1 # TRから送られるメッセージのoptionsの型が本来はHash型なのですが、 # 過去に配列になっていたバージョンがあったため、クラスをチェックします @options = {} unless @options.is_a?(Hash) @env = ["env"] || {} @headers = ['headers'] case @version when 1 @topic = @headers["Path-Info"] when 2 @topic = @env["PATH_INFO"] else raise "Unsupported request format version: #{@version}. Please update magellan-rails." end case ["body_encoding"] when /\Aplain\z/i, nil @body = ["body"] when /\Abase64\z/i @body = Base64.decode64(['body']) end end |