class Guacamole::DocumentModelMapper::Attribute
An attribute to encapsulate special mapping
Attributes
The name of the attribute with in the model
@return [Symbol] The name of the attribute
Additional options to be used for the mapping
@return [Hash] The mapping options for the attribute
Public Class Methods
Create a new attribute instance
You must at least provide the name of the attribute to be mapped and optionally pass configuration for the mapper when it processes this attribute.
@param [Symbol] name The name of the attribute @param [Hash] options Additional options to be passed @option options [Edge] :via The Edge
class this attribute relates to
# File lib/guacamole/document_model_mapper.rb, line 33 def initialize(name, options = {}) @name = name.to_sym @options = options end
Public Instance Methods
To Attribute
instances are equal if their name is equal
@param [Attribute] other The Attribute
to compare this one to @return [Boolean] True if both have the same name
# File lib/guacamole/document_model_mapper.rb, line 80 def ==(other) other.instance_of?(self.class) && other.name == name end
The edge class to be used during the mapping process
@return [Edge] The actual edge class
# File lib/guacamole/document_model_mapper.rb, line 68 def edge_class options[:via] end
# File lib/guacamole/document_model_mapper.rb, line 45 def get_value(model) value = model.send(getter) value.is_a?(Guacamole::Query) ? value.entries : value end
The name of the getter for this attribute
@returns [Symbol] The method name to read this attribute
# File lib/guacamole/document_model_mapper.rb, line 41 def getter name end
# File lib/guacamole/document_model_mapper.rb, line 72 def inverse? !!options[:inverse] end
Should this attribute be mapped via an Edge
in a Graph?
@return [Boolean] True if there was an edge class configured
# File lib/guacamole/document_model_mapper.rb, line 61 def map_via_edge? !!edge_class end
The name of the setter for this attribute
@return [String] The method name to set this attribute
# File lib/guacamole/document_model_mapper.rb, line 54 def setter "#{name}=" end