Class: BoffinIO::ListObject
Instance Attribute Summary
#api_key
Instance Method Summary
collapse
#[]=, #_dump, _load, #as_json, construct_from, #initialize, #inspect, #keys, #refresh_from, #respond_to?, #to_hash, #to_json, #to_s, #values
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class BoffinIO::BoffinIOObject
Instance Method Details
#[](k) ⇒ Object
4
5
6
7
8
9
10
11
|
# File 'lib/boffinio/list_object.rb', line 4
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
|
#all(params = {}, api_key = nil) ⇒ Object
29
30
31
32
33
|
# File 'lib/boffinio/list_object.rb', line 29
def all(params={}, api_key=nil)
api_key ||= @api_key
response, api_key = BoffinIO.request(:get, url, api_key, params)
Util.convert_to_boffinio_object(response, api_key)
end
|
#create(params = {}, api_key = nil) ⇒ Object
23
24
25
26
27
|
# File 'lib/boffinio/list_object.rb', line 23
def create(params={}, api_key=nil)
api_key ||= @api_key
response, api_key = BoffinIO.request(:post, url, api_key, params)
Util.convert_to_boffinio_object(response, api_key)
end
|
#each(&blk) ⇒ Object
13
14
15
|
# File 'lib/boffinio/list_object.rb', line 13
def each(&blk)
self.data.each(&blk)
end
|
#retrieve(id, api_key = nil) ⇒ Object
17
18
19
20
21
|
# File 'lib/boffinio/list_object.rb', line 17
def retrieve(id, api_key=nil)
api_key ||= @api_key
response, api_key = BoffinIO.request(:get,"#{url}/#{CGI.escape(id)}", api_key)
Util.convert_to_boffinio_object(response, api_key)
end
|