1
0
Fork 0
mirror of https://github.com/fog/fog-aws.git synced 2022-11-09 13:50:52 -05:00

make elb/policies collection standalone

* there is no need to inject data from the load balancer model when
  an index request exists that maps directly
This commit is contained in:
Josh Lane 2015-06-01 09:14:45 -07:00
parent f54f7fd95a
commit cdd724dff6
3 changed files with 26 additions and 22 deletions

View file

@ -143,23 +143,22 @@ module Fog
end end
def listeners def listeners
Fog::AWS::ELB::Listeners.new({ Fog::AWS::ELB::Listeners.new(
:data => attributes['ListenerDescriptions'], :data => attributes['ListenerDescriptions'],
:service => service, :service => service,
:load_balancer => self :load_balancer => self
}) )
end end
def policies def policies
Fog::AWS::ELB::Policies.new({ requires :id
:data => policy_descriptions,
:service => service, service.policies(:load_balancer_id => self.identity)
:load_balancer => self
})
end end
def policy_descriptions def policy_descriptions
requires :id requires :id
@policy_descriptions ||= service.describe_load_balancer_policies(id).body["DescribeLoadBalancerPoliciesResult"]["PolicyDescriptions"] @policy_descriptions ||= service.describe_load_balancer_policies(id).body["DescribeLoadBalancerPoliciesResult"]["PolicyDescriptions"]
end end

View file

@ -1,14 +1,23 @@
require 'fog/aws/models/elb/policy' require 'fog/aws/models/elb/policy'
module Fog module Fog
module AWS module AWS
class ELB class ELB
class Policies < Fog::Collection class Policies < Fog::Collection
attribute :load_balancer_id
model Fog::AWS::ELB::Policy model Fog::AWS::ELB::Policy
attr_accessor :data, :load_balancer def all(options={})
merge_attributes(options)
def all requires :load_balancer_id
load(munged_data)
data = service.describe_load_balancer_policies(self.load_balancer_id).
body["DescribeLoadBalancerPoliciesResult"]["PolicyDescriptions"]
load(munge(data))
end end
def get(id) def get(id)
@ -16,7 +25,8 @@ module Fog
end end
private private
def munged_data
def munge(data)
data.reduce([]) { |m,e| data.reduce([]) { |m,e|
policy_attribute_descriptions = e["PolicyAttributeDescriptions"] policy_attribute_descriptions = e["PolicyAttributeDescriptions"]

View file

@ -13,7 +13,6 @@ module Fog
def save def save
requires :id, :load_balancer requires :id, :load_balancer
service_method = nil
args = [load_balancer.id, id] args = [load_balancer.id, id]
if cookie_stickiness if cookie_stickiness
@ -45,12 +44,8 @@ module Fog
reload reload
end end
def reload
load_balancer.reload
end
def load_balancer def load_balancer
collection.load_balancer service.load_balancers.new(identity: collection.load_balancer_id)
end end
end end
end end