Class: Clerk::Resources::PluralResource
- Inherits:
-
Object
- Object
- Clerk::Resources::PluralResource
- Defined in:
- lib/clerk/resources/plural_resource.rb
Instance Method Summary collapse
- #all(query_params = {}) ⇒ Object
- #collection_path ⇒ Object
- #create(data = nil) ⇒ Object
- #delete(id) ⇒ Object
- #find(id) ⇒ Object
-
#initialize(client, path_prefix) ⇒ PluralResource
constructor
A new instance of PluralResource.
- #resource_path(id) ⇒ Object
- #update(id, changes = nil) ⇒ Object
Constructor Details
#initialize(client, path_prefix) ⇒ PluralResource
Returns a new instance of PluralResource.
4 5 6 7 |
# File 'lib/clerk/resources/plural_resource.rb', line 4 def initialize(client, path_prefix) @client = client @path_prefix = path_prefix end |
Instance Method Details
#all(query_params = {}) ⇒ Object
9 10 11 |
# File 'lib/clerk/resources/plural_resource.rb', line 9 def all(query_params = {}) @client.request(:get, collection_path, query: query_params) end |
#collection_path ⇒ Object
29 30 31 |
# File 'lib/clerk/resources/plural_resource.rb', line 29 def collection_path @path_prefix end |
#create(data = nil) ⇒ Object
17 18 19 |
# File 'lib/clerk/resources/plural_resource.rb', line 17 def create(data = nil) @client.request(:post, collection_path, body: data) end |
#delete(id) ⇒ Object
25 26 27 |
# File 'lib/clerk/resources/plural_resource.rb', line 25 def delete(id) @client.request(:delete, resource_path(id)) end |
#find(id) ⇒ Object
13 14 15 |
# File 'lib/clerk/resources/plural_resource.rb', line 13 def find(id) @client.request(:get, resource_path(id)) end |
#resource_path(id) ⇒ Object
33 34 35 |
# File 'lib/clerk/resources/plural_resource.rb', line 33 def resource_path(id) "#{@path_prefix}/#{id}" end |
#update(id, changes = nil) ⇒ Object
21 22 23 |
# File 'lib/clerk/resources/plural_resource.rb', line 21 def update(id, changes = nil) @client.request(:patch, resource_path(id), body: changes) end |