Class: Scalingo::Endpoint::Collection
Direct Known Subclasses
AccountKeys, AddonCategories, AddonProviders, Addons, Apps, Collaborators, Containers, Deployments, Domains, Events, Stats, Variables
Instance Attribute Summary
Attributes included from Base
#api, #prefix
Instance Method Summary
collapse
included
#resources
Methods included from Base
#initialize
Instance Method Details
#all ⇒ Object
Also known as:
to_a
61
62
63
|
# File 'lib/scalingo/endpoint.rb', line 61
def all
get[collection_name].map{|r| resource_class.new(self, r[find_by], r)}
end
|
#collection_name ⇒ Object
74
75
76
|
# File 'lib/scalingo/endpoint.rb', line 74
def collection_name
@collection_name ||= self.class.name.underscore.split('/').last
end
|
#each ⇒ Object
66
67
68
|
# File 'lib/scalingo/endpoint.rb', line 66
def each
block_given? ? all.each(&Proc.new) : all.each
end
|
#find(id) ⇒ Object
70
71
72
|
# File 'lib/scalingo/endpoint.rb', line 70
def find(id)
detect{|r| r[find_by] == id}
end
|
#find_by ⇒ Object
86
87
88
|
# File 'lib/scalingo/endpoint.rb', line 86
def find_by
'id'
end
|
#resource_class ⇒ Object
78
79
80
81
82
83
84
|
# File 'lib/scalingo/endpoint.rb', line 78
def resource_class
@resource_class ||= begin
Scalingo::Endpoint.const_get(self.class.name.singularize.split('::').last)
rescue
Resource
end
end
|