Sha256: 3cec46cef0e699de541c4a61d1560854c59052bfba4a7a5c6cac4e6498802a51
Contents?: true
Size: 1.74 KB
Versions: 6
Compression:
Stored size: 1.74 KB
Contents
module RESTinPeace class DefinitionProxy class ResourceMethodDefinitions def initialize(target) @target = target end 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, hash_for_updates) call.get end end 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, hash_for_updates) call.patch end end 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, hash_for_updates) call.post end end 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, hash_for_updates) call.put end end 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 end end end
Version data entries
6 entries across 6 versions & 1 rubygems