Class: JsonApiClient::Resource
- Inherits:
-
Object
- Object
- JsonApiClient::Resource
- Includes:
- Helpers::Associable, Helpers::Attributable, Helpers::CustomEndpoints, Helpers::Initializable, Helpers::Linkable, Helpers::Parsable, Helpers::Queryable, Helpers::Schemable, Helpers::Serializable
- Defined in:
- lib/json_api_client/resource.rb
Instance Attribute Summary collapse
-
#last_request_meta ⇒ Object
readonly
Returns the value of attribute last_request_meta.
Class Method Summary collapse
- .create(conditions = {}) ⇒ Object
- .find(conditions) ⇒ Object
-
.resource ⇒ Object
base URL for this resource.
- .resource_name ⇒ Object
- .run_request(query) ⇒ Object
- .table_name ⇒ Object
Instance Method Summary collapse
Methods included from Helpers::Linkable
Methods included from Helpers::Serializable
#as_json, #read_attribute_for_serialization
Methods included from Helpers::Attributable
#[], #[]=, #attributes=, #persisted?, #query_params, #respond_to?, #to_param, #update_attributes
Methods included from Helpers::Initializable
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class JsonApiClient::Helpers::Linkable
Instance Attribute Details
#last_request_meta ⇒ Object (readonly)
Returns the value of attribute last_request_meta.
59 60 61 |
# File 'lib/json_api_client/resource.rb', line 59 def @last_request_meta end |
Class Method Details
.create(conditions = {}) ⇒ Object
35 36 37 38 39 40 41 42 |
# File 'lib/json_api_client/resource.rb', line 35 def create(conditions = {}) result = run_request(Query::Create.new(self, conditions)) if result.has_errors? yield(result) if block_given? return nil end result.first end |
.find(conditions) ⇒ Object
31 32 33 |
# File 'lib/json_api_client/resource.rb', line 31 def find(conditions) run_request(Query::Find.new(self, conditions)) end |
.resource ⇒ Object
base URL for this resource
19 20 21 |
# File 'lib/json_api_client/resource.rb', line 19 def resource File.join(site, path) end |
.resource_name ⇒ Object
27 28 29 |
# File 'lib/json_api_client/resource.rb', line 27 def resource_name name.demodulize.underscore end |
.run_request(query) ⇒ Object
44 45 46 |
# File 'lib/json_api_client/resource.rb', line 44 def run_request(query) parse(connection.execute(query)) end |
.table_name ⇒ Object
23 24 25 |
# File 'lib/json_api_client/resource.rb', line 23 def table_name resource_name.pluralize end |