force group.auto_scaling_instances into a normal array
This commit is contained in:
@@ -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
|
||||
Reference in New Issue
Block a user