Sha256: 04804830a706e9d34f3ccd3937c976cca5f4fe3c7a5064b8965884929803466c
Contents?: true
Size: 1.71 KB
Versions: 5
Compression:
Stored size: 1.71 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, payload) 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, payload) 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, payload) 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, payload) 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
5 entries across 5 versions & 1 rubygems