Class: RESTinPeace::DefinitionProxy::ResourceMethodDefinitions
- Inherits:
-
Object
- Object
- RESTinPeace::DefinitionProxy::ResourceMethodDefinitions
- Defined in:
- lib/rest_in_peace/definition_proxy/resource_method_definitions.rb
Instance Method Summary collapse
- #delete(method_name, url_template) ⇒ Object
- #get(method_name, url_template, default_params = {}) ⇒ Object
-
#initialize(target) ⇒ ResourceMethodDefinitions
constructor
A new instance of ResourceMethodDefinitions.
- #patch(method_name, url_template) ⇒ Object
- #post(method_name, url_template) ⇒ Object
- #put(method_name, url_template) ⇒ Object
Constructor Details
#initialize(target) ⇒ ResourceMethodDefinitions
Returns a new instance of ResourceMethodDefinitions.
4 5 6 |
# File 'lib/rest_in_peace/definition_proxy/resource_method_definitions.rb', line 4 def initialize(target) @target = target end |
Instance Method Details
#delete(method_name, url_template) ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/rest_in_peace/definition_proxy/resource_method_definitions.rb', line 40 def delete(method_name, url_template) @target.rip_registry[:resource] << { method: :delete, name: method_name, url: url_template } @target.send(:define_method, method_name) do call = RESTinPeace::ApiCall.new(api, url_template, self, id: id) call.delete end end |
#get(method_name, url_template, default_params = {}) ⇒ Object
8 9 10 11 12 13 14 |
# File 'lib/rest_in_peace/definition_proxy/resource_method_definitions.rb', line 8 def get(method_name, url_template, default_params = {}) @target.rip_registry[:resource] << { method: :get, name: method_name, url: url_template } @target.send(:define_method, method_name) do call = RESTinPeace::ApiCall.new(api, url_template, self, payload) call.get end end |
#patch(method_name, url_template) ⇒ Object
16 17 18 19 20 21 22 |
# File 'lib/rest_in_peace/definition_proxy/resource_method_definitions.rb', line 16 def patch(method_name, url_template) @target.rip_registry[:resource] << { method: :patch, name: method_name, url: url_template } @target.send(:define_method, method_name) do call = RESTinPeace::ApiCall.new(api, url_template, self, payload) call.patch end end |
#post(method_name, url_template) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/rest_in_peace/definition_proxy/resource_method_definitions.rb', line 24 def post(method_name, url_template) @target.rip_registry[:resource] << { method: :post, name: method_name, url: url_template } @target.send(:define_method, method_name) do call = RESTinPeace::ApiCall.new(api, url_template, self, payload(false)) call.post end end |
#put(method_name, url_template) ⇒ Object
32 33 34 35 36 37 38 |
# File 'lib/rest_in_peace/definition_proxy/resource_method_definitions.rb', line 32 def put(method_name, url_template) @target.rip_registry[:resource] << { method: :put, name: method_name, url: url_template } @target.send(:define_method, method_name) do call = RESTinPeace::ApiCall.new(api, url_template, self, payload(false)) call.put end end |