Class: Patchboard::Response
- Inherits:
-
Object
- Object
- Patchboard::Response
- Defined in:
- lib/patchboard/response.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
-
#resource ⇒ Object
Returns the value of attribute resource.
Instance Method Summary collapse
-
#initialize(raw) ⇒ Response
constructor
A new instance of Response.
- #method_missing(name, *args, &block) ⇒ Object
- #respond_to?(*args) ⇒ Boolean
Constructor Details
#initialize(raw) ⇒ Response
Returns a new instance of Response.
6 7 8 9 10 11 12 13 |
# File 'lib/patchboard/response.rb', line 6 def initialize(raw) @raw = raw if @raw.headers["Content-Type"] if @raw.headers["Content-Type"] =~ %r{application/.*json} @data = JSON.parse @raw.body, :symbolize_names => true end end end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args, &block) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/patchboard/response.rb', line 15 def method_missing(name, *args, &block) if @raw.respond_to? name @raw.send(name, *args, &block) else super end end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the value of attribute data.
5 6 7 |
# File 'lib/patchboard/response.rb', line 5 def data @data end |
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
5 6 7 |
# File 'lib/patchboard/response.rb', line 5 def raw @raw end |
#resource ⇒ Object
Returns the value of attribute resource.
4 5 6 |
# File 'lib/patchboard/response.rb', line 4 def resource @resource end |
Instance Method Details
#respond_to?(*args) ⇒ Boolean
23 24 25 |
# File 'lib/patchboard/response.rb', line 23 def respond_to?(*args) @raw.respond_to?(*args) || super end |