Class: JsonSchemaClient::Resource
- Inherits:
-
Object
- Object
- JsonSchemaClient::Resource
- Defined in:
- lib/json_schema_client/resource.rb
Instance Attribute Summary collapse
-
#data ⇒ Object
readonly
Returns the Resource data.
-
#response ⇒ Object
readonly
Returns the HTTP response object for the Resource.
-
#schema ⇒ Object
readonly
Returns the Resource Schema.
Instance Method Summary collapse
-
#initialize(data, schema, entry_point, response = nil) ⇒ Resource
constructor
A new instance of Resource.
- #method_missing(method_name, *args, &block) ⇒ Object
Constructor Details
#initialize(data, schema, entry_point, response = nil) ⇒ Resource
Returns a new instance of Resource.
20 21 22 23 24 25 |
# File 'lib/json_schema_client/resource.rb', line 20 def initialize(data, schema, entry_point, response = nil) @data = OpenStruct.new(data) @schema = schema @entry_point = entry_point @response = response end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
27 28 29 |
# File 'lib/json_schema_client/resource.rb', line 27 def method_missing(method_name, *args, &block) @data.send(method_name, *args, &block) || super end |
Instance Attribute Details
#data ⇒ Object (readonly)
Returns the Resource data.
9 10 11 |
# File 'lib/json_schema_client/resource.rb', line 9 def data @data end |
#response ⇒ Object (readonly)
Returns the HTTP response object for the Resource.
18 19 20 |
# File 'lib/json_schema_client/resource.rb', line 18 def response @response end |
#schema ⇒ Object (readonly)
Returns the Resource Schema.
12 13 14 |
# File 'lib/json_schema_client/resource.rb', line 12 def schema @schema end |