class Unparser::Anima::Attribute
An attribute
Attributes
instance_variable_name[R]
Return instance variable name
@return [Symbol]
name[R]
Return attribute name
@return [Symbol]
Public Class Methods
new(name)
click to toggle source
Initialize attribute
@param [Symbol] name
# File lib/unparser/anima/attribute.rb, line 12 def initialize(name) @name = name @instance_variable_name = :"@#{name}" end
Public Instance Methods
get(object)
click to toggle source
Get attribute value from object
@param [Object] object
@return [Object]
# File lib/unparser/anima/attribute.rb, line 42 def get(object) object.public_send(name) end
load(object, attributes)
click to toggle source
Load attribute
@param [Object] object @param [Hash] attributes
@return [self]
# File lib/unparser/anima/attribute.rb, line 33 def load(object, attributes) set(object, attributes.fetch(name)) end
set(object, value)
click to toggle source
Set attribute value in object
@param [Object] object @param [Object] value
@return [self]
# File lib/unparser/anima/attribute.rb, line 52 def set(object, value) object.instance_variable_set(instance_variable_name, value) self end