Sha256: 03d13cdab4a9c6ae43845e55af0d1a1891c7fee0bbc40df5d3f142c00eed3570
Contents?: true
Size: 1.07 KB
Versions: 6
Compression:
Stored size: 1.07 KB
Contents
module Rainforest class ListObject < RainforestObject def [](k) case k when String, Symbol super else raise ArgumentError.new("You tried to access the #{k.inspect} index, but ListObject types only support String keys. (HINT: List calls return an object with a 'data' (which is the data array). You likely want to call #data[#{k.inspect}])") end end def each(&blk) self.data.each(&blk) end def retrieve(id, api_key=nil) api_key ||= @api_key response, api_key = Rainforest.request(:get,"#{url}/#{CGI.escape(id)}", api_key) Util.convert_to_rainforest_object(response, api_key) end def create(params={}, api_key=nil) api_key ||= @api_key response, api_key = Rainforest.request(:post, url, api_key, params) Util.convert_to_rainforest_object(response, api_key) end def all(params={}, api_key=nil) api_key ||= @api_key response, api_key = Rainforest.request(:get, url, api_key, params) Util.convert_to_rainforest_object(response, api_key) end end end
Version data entries
6 entries across 6 versions & 1 rubygems