class AWS::Core::Resource::AttributeProvider
@private
def attributes_from_response resource, response
def attributes_from_response resource, response if response_object = resource.send(finder_method, response) attributes_from_response_object(response_object) else {} end end
def attributes_from_response_object resp_obj
def attributes_from_response_object resp_obj attributes = {} @provides.each do |attr_name, options| attr = @klass.attributes[attr_name] method = options[:get_as] || attr.get_as v = resp_obj.respond_to?(method) ? resp_obj.send(method) : nil v = v.value if v and options[:value_wrapped] v = attr.translate_output_value(v) attributes[attr_name] = v end attributes end
def find &block
def find &block @klass.send(:define_method, finder_method, &block) end
def finder_method
def finder_method "find_in_response_#{@id}" end
def initialize klass, request_types
def initialize klass, request_types @klass = klass @id = klass.attribute_providers.length @request_types = request_types @provides = {} end
def provides *attr_names
(**options)
-
:get_as
(Symbol
) -- Defaults to the method named -
:value_wrapped
(Boolean
) -- If true, then
Parameters:
-
options
(Hash
) -- -
attr_names
(Symbol
) -- A list of attributes provided
def provides *attr_names options = attr_names.last.is_a?(Hash) ? attr_names.pop : {} attr_names.each do |attr_name| attr = @klass.attributes[attr_name] attr.request_types.push(*request_types) @provides[attr_name] = options end end