Class: Conjure::Instance::Collection

Inherits:
Object
  • Object
show all
Includes:
Enumerable
Defined in:
lib/conjure/instance.rb

Instance Method Summary collapse

Constructor Details

#initialize(options) ⇒ Collection

Returns a new instance of Collection.



85
86
87
# File 'lib/conjure/instance.rb', line 85

def initialize(options)
  @origin = options[:origin]
end

Instance Method Details

#application_nameObject



89
90
91
# File 'lib/conjure/instance.rb', line 89

def application_name
  Application.new(:origin => @origin).name
end

#each(&block) ⇒ Object



93
94
95
96
97
98
99
# File 'lib/conjure/instance.rb', line 93

def each(&block)
  return unless @origin
  Service::CloudServer.each_with_name_prefix("#{application_name}-") do |server|
    match = server.name.match(/^#{application_name}-([^-]+)(-[0-9]+)?$/)
    yield Instance.new(:server => server) if match
  end
end