force group.auto_scaling_instances into a normal array
This commit is contained in:
parent
d81c8679dd
commit
67a47cac28
|
@ -98,7 +98,7 @@ module AwsMissingTools
|
|||
@group.update(desired_capacity: @group.desired_capacity + @opts[:num_simultaneous_instances])
|
||||
|
||||
puts "The list of instances in Auto Scaling Group #{@group.name} that will be terminated is:\n#{@group.auto_scaling_instances.map{ |i| i.ec2_instance.id }.to_ary}"
|
||||
@group.auto_scaling_instances.each_slice(@opts[:num_simultaneous_instances]) do |instances|
|
||||
@group.auto_scaling_instances.to_a.each_slice(@opts[:num_simultaneous_instances]) do |instances|
|
||||
time_taken = 0
|
||||
|
||||
until all_instances_inservice_for_time_period?(@group.load_balancers, INSERVICE_POLLING_TIME)
|
||||
|
|
|
@ -48,7 +48,7 @@ module AWS
|
|||
end
|
||||
|
||||
def auto_scaling_instances
|
||||
@auto_scaling_instances ||= [AWS::FakeAutoScaling::Instance.new(self), AWS::FakeAutoScaling::Instance.new(self)]
|
||||
@auto_scaling_instances ||= AWS::FakeCore::Data::List.new [AWS::FakeAutoScaling::Instance.new(self), AWS::FakeAutoScaling::Instance.new(self)]
|
||||
end
|
||||
|
||||
def load_balancers
|
||||
|
|
71
spec/support/fake_core_data_list.rb
Normal file
71
spec/support/fake_core_data_list.rb
Normal file
|
@ -0,0 +1,71 @@
|
|||
module AWS
|
||||
module FakeCore
|
||||
class Data
|
||||
module MethodMissingProxy
|
||||
|
||||
protected
|
||||
|
||||
def method_missing *args, &block
|
||||
if block_given?
|
||||
return_value = @data.send(*args) do |*values|
|
||||
yield(*values.flatten.map{|v| Data.cast(v) })
|
||||
end
|
||||
Data.cast(return_value)
|
||||
else
|
||||
Data.cast(@data.send(*args))
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
include MethodMissingProxy
|
||||
|
||||
def method_missing method_name, *args, &block
|
||||
if
|
||||
args.empty? and !block_given? and
|
||||
key = _remove_question_mark(method_name) and
|
||||
@data.has_key?(key)
|
||||
then
|
||||
Data.cast(@data[key])
|
||||
else
|
||||
super
|
||||
end
|
||||
end
|
||||
|
||||
class << self
|
||||
|
||||
# Given a hash, this method returns a {Data} object. Given
|
||||
# an Array, this method returns a {Data::List} object. Everything
|
||||
# else is returned as is.
|
||||
#
|
||||
# @param [Object] value The value to conditionally wrap.
|
||||
#
|
||||
# @return [Data,Data::List,Object] Wraps hashes and lists with
|
||||
# Data and List objects, all other objects are returned as
|
||||
# is.
|
||||
#
|
||||
def cast value
|
||||
case value
|
||||
when Hash then Data.new(value)
|
||||
when Array then Data::List.new(value)
|
||||
else value
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class List
|
||||
include MethodMissingProxy
|
||||
|
||||
def initialize(array)
|
||||
@data = array
|
||||
end
|
||||
|
||||
def to_ary
|
||||
@data
|
||||
end
|
||||
alias_method :to_a, :to_ary
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user