Class: AWS::ELB::LoadBalancerPolicy

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

Instance Attribute Summary collapse

Attributes included from Core::Model

#config

Instance Method Summary collapse

Methods inherited from Core::Resource

attribute_providers, attribute_providers_for, attributes, #attributes_from_response, define_attribute_type, #eql?, #inspect, new_from

Methods included from Core::Cacheable

included, #retrieve_attribute

Methods included from Core::Model

#client, #config_prefix, #inspect

Constructor Details

#initialize(load_balancer, name, options = {}) ⇒ LoadBalancerPolicy

Returns a new instance of LoadBalancerPolicy.


19
20
21
22
# File 'lib/aws/elb/load_balancer_policy.rb', line 19

def initialize load_balancer, name, options = {}
  @load_balancer = load_balancer
  super(load_balancer, options.merge(:name => name.to_s))
end

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