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
- #respond_to_missing?(method_name, _include_private = false) ⇒ Boolean
Constructor Details
#initialize(response) ⇒ Resource
Returns a new instance of Resource.
7 8 9 10 11 12 13 14 15 |
# File 'lib/rollbar_api/resource.rb', line 7 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
22 23 24 |
# File 'lib/rollbar_api/resource.rb', line 22 def method_missing(name, *args) @struct.send(name, *args) end |
Instance Attribute Details
#response_json ⇒ Object (readonly)
Returns the value of attribute response_json.
5 6 7 |
# File 'lib/rollbar_api/resource.rb', line 5 def response_json @response_json end |
Instance Method Details
#as_json(_options = {}) ⇒ Object
18 19 20 |
# File 'lib/rollbar_api/resource.rb', line 18 def as_json( = {}) @response_json end |
#respond_to_missing?(method_name, _include_private = false) ⇒ Boolean
26 27 28 |
# File 'lib/rollbar_api/resource.rb', line 26 def respond_to_missing?(method_name, _include_private = false) @struct.respond_to?(method_name) end |