Module: Protip::Resource::ExtraMethods
- Defined in:
- lib/protip/resource/extra_methods.rb
Overview
Internal helpers for non-resourceful member/collection methods. Never use these directly; instead, use the instance/class methods which have been dynamically defined on the resource you’re working with.
Class Method Summary collapse
- .collection(resource_class, action, method, message, response_type) ⇒ Object
- .member(resource, action, method, message, response_type) ⇒ Object
Class Method Details
.collection(resource_class, action, method, message, response_type) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/protip/resource/extra_methods.rb', line 14 def self.collection(resource_class, action, method, , response_type) response = resource_class.client.request path: "#{resource_class.base_path}/#{action}", method: method, message: , response_type: response_type nil == response ? nil : ::Protip::Wrapper.new(response, resource_class.converter) end |
.member(resource, action, method, message, response_type) ⇒ Object
7 8 9 10 11 12 13 |
# File 'lib/protip/resource/extra_methods.rb', line 7 def self.member(resource, action, method, , response_type) response = resource.class.client.request path: "#{resource.class.base_path}/#{resource.id}/#{action}", method: method, message: , response_type: response_type nil == response ? nil : ::Protip::Wrapper.new(response, resource.class.converter) end |