class SoftLayer::DynamicAttribute::DynamicAttributeDefinition

The DynamicAttributeDefinition inner class is to collect and store information about how and when a sl_dynamic_attr should be updated. This class is an implementation detail of dynamic attributes and is not intended to be useful outside of that context.

Attributes

attribute_name[R]

the name of the attribute this definition is for

should_update_block[R]

The block to call to see if the attribute needs to be updated.

update_block[R]

The block to call in order to update the attribute. The return value of this block should be the new value of the attribute.

Public Class Methods

new(attribute_name) click to toggle source
# File lib/softlayer/DynamicAttribute.rb, line 74
def initialize(attribute_name)
  raise ArgumentError if attribute_name.nil?
  raise ArgumentError if attribute_name.to_s.empty?

  @attribute_name = attribute_name;
  @update_block = Proc.new { nil; };
  @should_update_block = Proc.new { true; }
end

Public Instance Methods

should_update?(&block) click to toggle source

This method is used to provide behavior for the should_update_ predicate for the attribute

# File lib/softlayer/DynamicAttribute.rb, line 85
def should_update? (&block)
  @should_update_block = block
end
to_update(&block) click to toggle source

This method is used to provide the behavior for the update_! method for the attribute.

# File lib/softlayer/DynamicAttribute.rb, line 91
def to_update (&block)
  @update_block = block
end