Class: Scalingo::Endpoint::Collection
Direct Known Subclasses
AccountKeys, AddonCategories, AddonProviders, Addons, Alerts, Apps, Autoscalers, Collaborators, Containers, Deployments, Domains, Events, Notifiers, Regions, Stats, Variables
Instance Attribute Summary
Attributes included from Base
#api, #auth_api, #prefix
Instance Method Summary
collapse
included
#resources
Methods included from Base
#initialize
Instance Method Details
#all ⇒ Object
Also known as:
to_a
72
73
74
|
# File 'lib/scalingo/endpoint.rb', line 72
def all
get[collection_name].map { |r| resource_class.new(self, r[find_by], {}, r) }
end
|
#collection_name ⇒ Object
85
86
87
|
# File 'lib/scalingo/endpoint.rb', line 85
def collection_name
@collection_name ||= self.class.name.underscore.split('/').last
end
|
#each ⇒ Object
77
78
79
|
# File 'lib/scalingo/endpoint.rb', line 77
def each
block_given? ? all.each(&Proc.new) : all.each
end
|
#find(id) ⇒ Object
81
82
83
|
# File 'lib/scalingo/endpoint.rb', line 81
def find(id)
detect { |r| r[find_by] == id }
end
|
#find_by ⇒ Object
97
98
99
|
# File 'lib/scalingo/endpoint.rb', line 97
def find_by
'id'
end
|
#resource_class ⇒ Object
89
90
91
92
93
94
95
|
# File 'lib/scalingo/endpoint.rb', line 89
def resource_class
@resource_class ||= begin
Scalingo::Endpoint.const_get(self.class.name.singularize.split('::').last)
rescue
Resource
end
end
|