Class: WCC::Data::Response
- Inherits:
-
Object
- Object
- WCC::Data::Response
- Defined in:
- lib/wcc/data/response.rb
Instance Attribute Summary collapse
-
#raw ⇒ Object
readonly
Returns the value of attribute raw.
Instance Method Summary collapse
-
#initialize(raw) ⇒ Response
constructor
A new instance of Response.
- #json ⇒ Object
- #method_missing(method, *args, &block) ⇒ Object
- #respond_to?(method) ⇒ Boolean
Constructor Details
#initialize(raw) ⇒ Response
Returns a new instance of Response.
7 8 9 |
# File 'lib/wcc/data/response.rb', line 7 def initialize(raw) @raw = raw end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/wcc/data/response.rb', line 16 def method_missing(method, *args, &block) if raw.respond_to?(method) raw.public_send(method, *args, &block) else super end end |
Instance Attribute Details
#raw ⇒ Object (readonly)
Returns the value of attribute raw.
5 6 7 |
# File 'lib/wcc/data/response.rb', line 5 def raw @raw end |
Instance Method Details
#json ⇒ Object
11 12 13 14 |
# File 'lib/wcc/data/response.rb', line 11 def json JSON.parse(body) rescue JSON::ParserError end |
#respond_to?(method) ⇒ Boolean
24 25 26 |
# File 'lib/wcc/data/response.rb', line 24 def respond_to?(method) super || raw.respond_to?(method) end |