class RemoteResource::AttributeSpecification
A value object representing an attribute defined in RemoteResource::Base
. An AttributeSpecification
contains the attributes’ method name, its resource, and its API client that is used for lookup. It also calculates its ‘key` which is used to lookup its value in storage.
scope is evaluated outside of this object and should remain unchanged throughout its life cycle. scope is used in building the attribute’s key and its equality. target_object on the other hand is just a reference to the object that scope was evaluated on. It may change throughout the attribute’s life cycle and is not used in determining equality.
Attributes
base_class[R]
method[R]
name[R]
Public Class Methods
new(name, base_class)
click to toggle source
# File lib/remote_resource/attribute_specification.rb, line 19 def initialize(name, base_class) @name = name @base_class = base_class end
Public Instance Methods
key()
click to toggle source
# File lib/remote_resource/attribute_specification.rb, line 46 def key @key ||= AttributeKey.new(@base_class.class.underscore, resource_name, @base_class.scope, @name) end
location()
click to toggle source
# File lib/remote_resource/attribute_specification.rb, line 42 def location "#{@base_class.class.name}##{@name}" end
resource(resource_client = nil)
click to toggle source
# File lib/remote_resource/attribute_specification.rb, line 38 def resource(resource_client = nil) @base_class.send(:resource, resource_name, resource_client) end
resource_name()
click to toggle source
# File lib/remote_resource/attribute_specification.rb, line 34 def resource_name @base_class.class.attributes[@name] end
to_hash()
click to toggle source
# File lib/remote_resource/attribute_specification.rb, line 25 def to_hash { name: @name, resource: resource_name, base_class: @base_class.class.symbol_name, location: location } end