Class: RollbarApi::Resource
- Inherits:
-
Object
- Object
- RollbarApi::Resource
- Defined in:
- lib/rollbar-api/resource.rb
Instance Attribute Summary collapse
-
#response_json ⇒ Object
readonly
Returns the value of attribute response_json.
Instance Method Summary collapse
- #as_json(options = {}) ⇒ Object
-
#initialize(response) ⇒ Resource
constructor
A new instance of Resource.
- #method_missing(name, *args) ⇒ Object
Constructor Details
#initialize(response) ⇒ Resource
Returns a new instance of Resource.
5 6 7 8 9 10 11 12 13 |
# File 'lib/rollbar-api/resource.rb', line 5 def initialize(response) response = response.body if response.is_a?(Faraday::Response) @response_json = if response.is_a?(String) JSON.parse(response) else response end @struct = ResourceStruct.new(@response_json, {recurse_over_arrays: true}) end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(name, *args) ⇒ Object
20 21 22 |
# File 'lib/rollbar-api/resource.rb', line 20 def method_missing(name, *args) @struct.send(name, *args) end |
Instance Attribute Details
#response_json ⇒ Object (readonly)
Returns the value of attribute response_json.
3 4 5 |
# File 'lib/rollbar-api/resource.rb', line 3 def response_json @response_json end |
Instance Method Details
#as_json(options = {}) ⇒ Object
16 17 18 |
# File 'lib/rollbar-api/resource.rb', line 16 def as_json( = {}) @response_json end |