Sha256: 92d37a2315a29b8969c4752c1b575fa735274c0cee2a4993ce8ce3c68be7312f

Contents?: true

Size: 689 Bytes

Versions: 1

Compression:

Stored size: 689 Bytes

Contents

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
      Hashie::Mash.new hash
    end

    protected

    def set_path(pa)
      @path = pa
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rubyoverflow-2.0.2.pre1 lib/rubyoverflow/base.rb