Class: AWS::ELB::LoadBalancerPolicy

Inherits:
Core::Resource
  • Object
show all
Defined in:
lib/aws/elb/load_balancer_policy.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#load_balancerLoadBalancer (readonly)

Returns the load balancer this policy belongs to.

Returns:

  • (LoadBalancer)

    Returns the load balancer this policy belongs to.



25
26
27
# File 'lib/aws/elb/load_balancer_policy.rb', line 25

def load_balancer
  @load_balancer
end

Instance Method Details

#attributesHash

Returns a hash of policy attributes. Keys are policy attribute names, and values are arrays one or more policy attribute values.

Returns:

  • (Hash)

    Returns a hash of policy attributes. Keys are policy attribute names, and values are arrays one or more policy attribute values.



46
47
48
49
50
51
52
53
# File 'lib/aws/elb/load_balancer_policy.rb', line 46

def attributes
  attributes = {}
  policy_attribute_descriptions.each do |desc|
    attributes[desc.attribute_name] ||= []
    attributes[desc.attribute_name] << desc.attribute_value
  end
  attributes
end

#deletenil

Deletes this load balancer policy.

Returns:

  • (nil)


57
58
59
60
61
62
63
64
65
# File 'lib/aws/elb/load_balancer_policy.rb', line 57

def delete

  client.delete_load_balancer_policy(
    :load_balancer_name => load_balancer.name,
    :policy_name => name)

  nil

end

#exists?Boolean

Useful for determining if a policy with the given name exists:

load_balancer.policies['my-policy-name'].exists?  # => true/false

Returns:

  • (Boolean)

    Returns true this policy’s load balancer has a policy with this name.



73
74
75
76
77
78
# File 'lib/aws/elb/load_balancer_policy.rb', line 73

def exists?
  r = get_resource
  r.policy_descriptions.find{|d| d.policy_name == name } ? true : false
rescue AWS::ELB::Errors::LoadBalancerNotFound
  false
end