Skip to content

Instantly share code, notes, and snippets.

@drochetti
Created September 18, 2014 15:48
Show Gist options
  • Save drochetti/0c38d9b98863a2c3cfad to your computer and use it in GitHub Desktop.
Save drochetti/0c38d9b98863a2c3cfad to your computer and use it in GitHub Desktop.
ruby rest client poc
module Blowout
module Api
class BaseResource < Hashie::Mash
# include RestCore
# include Blowout::Api
# include Blowout::Api::Client
def self.set_client(client)
@client = client
end
def self.client
@client || Blowout::Api::Client.new
end
def self.find(id, *cb)
client.get "#{base_path}/#{id}"
end
def self.fetch(filter={}, *cb)
get "#{base_path}"
end
def create(*cb)
post "#{base_path}"
end
def update(*cb)
put "#{base_path}/#{id}"
end
def destroy(*cb)
delete "#{base_path}/#{id}"
end
protected
def self.resource_name
self.name.split('::').last.downcase
end
def self.base_path
"/#{resource_name}/"
end
end
end
end
@julioprotzek
Copy link

What exactly is not working the way it should?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment