From ef47f6316ead386f9274f5c4bc4f828946e0ef54 Mon Sep 17 00:00:00 2001 From: David Faber Date: Thu, 19 Sep 2013 15:53:12 -0700 Subject: [PATCH] Use ruby-style attribute setters in AutoScaling::Group initializer --- lib/fog/aws/models/auto_scaling/group.rb | 24 ++++++++++---------- tests/aws/models/auto_scaling/groups_test.rb | 5 ++++ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/lib/fog/aws/models/auto_scaling/group.rb b/lib/fog/aws/models/auto_scaling/group.rb index 9cde50d8c..8b7dd7132 100644 --- a/lib/fog/aws/models/auto_scaling/group.rb +++ b/lib/fog/aws/models/auto_scaling/group.rb @@ -25,18 +25,18 @@ module Fog attribute :vpc_zone_identifier, :aliases => 'VPCZoneIdentifier' def initialize(attributes={}) - attributes['DefaultCooldown'] ||= 300 - attributes['DesiredCapacity'] ||= 0 - attributes['EnabledMetrics'] ||= [] - attributes['HealthCheckGracePeriod'] ||= 0 - attributes['HealthCheckType'] ||= 'EC2' - attributes['Instances'] ||= [] - attributes['LoadBalancerNames'] ||= [] - attributes['MaxSize'] ||= 0 - attributes['MinSize'] ||= 0 - attributes['SuspendedProcesses'] ||= [] - attributes['Tags'] ||= [] - attributes['TerminationPolicies'] ||= ['Default'] + attributes['Instances'] = [] + self.default_cooldown = 300 + self.desired_capacity = 0 + self.enabled_metrics = [] + self.health_check_grace_period = 0 + self.health_check_type = 'EC2' + self.load_balancer_names = [] + self.max_size = 0 + self.min_size = 0 + self.suspended_processes = [] + self.tags = [] + self.termination_policies = ['Default'] super end diff --git a/tests/aws/models/auto_scaling/groups_test.rb b/tests/aws/models/auto_scaling/groups_test.rb index 43874727f..fb6246436 100644 --- a/tests/aws/models/auto_scaling/groups_test.rb +++ b/tests/aws/models/auto_scaling/groups_test.rb @@ -18,5 +18,10 @@ Shindo.tests('AWS::AutoScaling | group', ['aws', 'auto_scaling_m']) do model_tests(Fog::AWS[:auto_scaling].groups, params, true) do @instance.update end + + test("setting attributes in the constructor") do + group = Fog::AWS[:auto_scaling].groups.new(min_size: 1, max_size: 2) + group.min_size == 1 && group.max_size == 2 + end end