Created
September 18, 2014 15:48
-
-
Save drochetti/0c38d9b98863a2c3cfad to your computer and use it in GitHub Desktop.
ruby rest client poc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
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
This is the class that all resource models will inherit from, for example: