Sha256: af074452083288f367fe9097ebe95ce552bc98602c781f1569aab9d01fb581bd
Contents?: true
Size: 855 Bytes
Versions: 3
Compression:
Stored size: 855 Bytes
Contents
class RestCRUDService attr_reader :path attr_reader :object attr_reader :browser def initialize(params = {}) defaults = { :path => '/api/', :object => '', :browser => Rack::Test::Session.new(Rack::MockSession.new(Sinatra::Application)) } defaults.merge! params @path = defaults[:path] @object = defaults[:object] @browser = defaults[:browser] end def url return "#{@path}/#{@object}" end def create_record _data return @browser.post self.url, _data end def retrieve_all_records return @browser.get self.url end def retrieve_record _nb return @browser.get "#{self.url}/#{_nb}" end def update_record _nb,_data return @browser.put "#{self.url}/#{_nb}", _data end def destroy_record _nb return @browser.delete "#{self.url}/#{_nb}" end end
Version data entries
3 entries across 3 versions & 1 rubygems