Class: Maestrano::API::ListObject
- Inherits:
-
Object
- Object
- Object
- Maestrano::API::ListObject
show all
- Defined in:
- lib/maestrano/api/list_object.rb
Instance Attribute Summary
Attributes inherited from Object
#api_token
Instance Method Summary
collapse
Methods inherited from Object
#[]=, #_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 Maestrano::API::Object
Instance Method Details
5
6
7
8
9
10
11
12
|
# File 'lib/maestrano/api/list_object.rb', line 5
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_token = nil) ⇒ Object
30
31
32
33
34
|
# File 'lib/maestrano/api/list_object.rb', line 30
def all(params={}, api_token=nil)
api_token ||= @api_token
response, api_token = Maestrano::API::Operation::Base.request(:get, url, api_token, params)
Util.convert_to_maestrano_object(response, api_token)
end
|
#create(params = {}, api_token = nil) ⇒ Object
24
25
26
27
28
|
# File 'lib/maestrano/api/list_object.rb', line 24
def create(params={}, api_token=nil)
api_token ||= @api_token
response, api_token = Maestrano::API::Operation::Base.request(:post, url, api_token, params)
Util.convert_to_maestrano_object(response, api_token)
end
|
#each(&blk) ⇒ Object
14
15
16
|
# File 'lib/maestrano/api/list_object.rb', line 14
def each(&blk)
self.data.each(&blk)
end
|
#retrieve(id, api_token = nil) ⇒ Object
18
19
20
21
22
|
# File 'lib/maestrano/api/list_object.rb', line 18
def retrieve(id, api_token=nil)
api_token ||= @api_token
response, api_token = Maestrano::API::Operation::Base.request(:get,"#{url}/#{CGI.escape(id)}", api_token)
Util.convert_to_maestrano_object(response, api_token)
end
|