Skip to content

Instantly share code, notes, and snippets.

@danmcclain
Created November 25, 2011 21:32
Show Gist options
  • Select an option

  • Save danmcclain/1394463 to your computer and use it in GitHub Desktop.

Select an option

Save danmcclain/1394463 to your computer and use it in GitHub Desktop.
module Rubyoverflow
class Base
def initialize(client)
@client = client
end
def fetch(params = {})
ids = params.delete(:id) if params[:id]
ids = ids.join(';') if ids and ids.kind_of? Array
hash,url = @client.request "#{@path}#{"/#{ids}" if ids}", params
Hashie::Mash.new hash
end
def method_missing(name, *args, &block)
params = args.first
ids = params.delete(:id) if params[:id]
ids = ids.join(';') if ids and ids.kind_of? Array
hash,url = @client.request "#{@path}#{"/#{ids}" if ids}/#{name}", params
end
protected
def set_path(pa)
@path = pa
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment