class Maestrano::API::ListObject
Public Instance Methods
[](k)
click to toggle source
Calls superclass method
Maestrano::API::Object#[]
# 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)
click to toggle source
# 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)
click to toggle source
# 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)
click to toggle source
# File lib/maestrano/api/list_object.rb, line 14 def each(&blk) self.data.each(&blk) end
retrieve(id, api_token=nil)
click to toggle source
# 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