class AWS::EC2::Resource

@private

Protected Class Methods

describe_call_attribute(name, opts = {}, &blk) click to toggle source

@private

# File lib/aws/ec2/resource.rb, line 148
def describe_call_attribute(name, opts = {}, &blk)
  attribute(name, opts, &blk)
end

Protected Instance Methods

__resource_id__() click to toggle source
# File lib/aws/ec2/resource.rb, line 27
def __resource_id__
  send(resource_id_method)
end
describe_attribute_call(attribute) click to toggle source
# File lib/aws/ec2/resource.rb, line 76
def describe_attribute_call(attribute)
  name = describe_attribute_call_name

  attr_opt_name = Core::Inflection.class_name(attribute.get_as.to_s)
  attr_opt_name = attr_opt_name[0,1].downcase + attr_opt_name[1..-1]

  client.send(name, Hash[[[response_id_method.to_sym,
                           __resource_id__],
                          [:attribute, attr_opt_name]]])
end
describe_call() click to toggle source
# File lib/aws/ec2/resource.rb, line 70
def describe_call
  options = { :"#{response_id_method}s" => [__resource_id__] }
  client.send(describe_call_name, options)
end
find_in_response(response) click to toggle source

required for tagged item, which most ec2 resources are

# File lib/aws/ec2/resource.rb, line 98
def find_in_response response
  self.class.attribute_providers.each do |provider|
    if provider.request_types.include?(response.request_type)
      return send(provider.finder_method, response)
    end
  end
end
get_resource(attribute) click to toggle source
# File lib/aws/ec2/resource.rb, line 55
def get_resource attribute
  describe_call
end
resource_id_method() click to toggle source
# File lib/aws/ec2/resource.rb, line 38
def resource_id_method
  @resource_id_method ||=
    case
    when respond_to?(:id) && method(:id).owner != Kernel
      # id isn't defined on Object in some Ruby versions, in
      # others it is an alias for object_id; if the method is
      # not owned by Kernel we can assume that it has been
      # overridden in a subclass
      :id
    when respond_to?(:name)
      :name
    else
      raise NotImplementedError
    end
end
resource_identifiers() click to toggle source

@private

# File lib/aws/ec2/resource.rb, line 22
def resource_identifiers
  [[resource_id_method, send(resource_id_method)]]
end
response_id_method() click to toggle source
# File lib/aws/ec2/resource.rb, line 32
def response_id_method
  # e.g. instance_id
  inflected_name + "_" + resource_id_method.to_s
end
retrieve_attribute(attribute_or_attribute_name, &block) click to toggle source
# File lib/aws/ec2/resource.rb, line 60
def retrieve_attribute attribute_or_attribute_name, &block
  if attribute_or_attribute_name.is_a?(Symbol)
    attribute = self.class.attributes[attribute_or_attribute_name]
  else
    attribute = attribute_or_attribute_name
  end
  super(attribute, &block)
end
update_resource(attribute, value) click to toggle source
# File lib/aws/ec2/resource.rb, line 88
def update_resource attribute, value
  options = {}
  options[attribute.set_as] = { :value => value }
  options[:"#{inflected_name}_id"] = __resource_id__
  method_name = "modify_#{inflected_name}_attribute"
  client.send(method_name, options)
end