Module: ContextIO::API::Resource
- Included in:
- ContextIO::Account, ConnectToken, Contact, File, Message, OAuthProvider, Source, Thread, Webhook
- Defined in:
- lib/contextio/api/resource.rb
Overview
When include
d into a class, this module provides some helper methods for
various things a singular resource will need or find useful.
Defined Under Namespace
Modules: DeclarativeClassSyntax
Instance Attribute Summary collapse
-
#api_attributes ⇒ {String => Numeric, String, Hash, Array, Boolean}
readonly
The attributes returned from the API as a Hash.
-
#primary_key ⇒ String, Symbol
readonly
The name of the key used to build the resource URL.
-
#resource_url ⇒ String
readonly
The URL that will fetch attributes from the API.
Instance Method Summary collapse
-
#delete ⇒ Boolean
Deletes the resource.
Instance Attribute Details
#api_attributes ⇒ {String => Numeric, String, Hash, Array, Boolean} (readonly)
Returns The attributes returned from the API as a Hash. If it hasn't been populated, it will ask the API and populate it.
60 61 62 |
# File 'lib/contextio/api/resource.rb', line 60 def api_attributes @api_attributes ||= fetch_attributes end |
#primary_key ⇒ String, Symbol (readonly)
Returns The name of the key used to build the resource URL.
67 68 69 |
# File 'lib/contextio/api/resource.rb', line 67 def primary_key self.class.primary_key end |
#resource_url ⇒ String (readonly)
Returns The URL that will fetch attributes from the API.
45 46 47 |
# File 'lib/contextio/api/resource.rb', line 45 def resource_url @resource_url ||= api.url_for(self) end |
Instance Method Details
#delete ⇒ Boolean
Deletes the resource.
52 53 54 |
# File 'lib/contextio/api/resource.rb', line 52 def delete api.request(:delete, resource_url)['success'] end |