Class: ActiveNode::Reflection::MacroReflection
- Inherits:
-
Object
- Object
- ActiveNode::Reflection::MacroReflection
- Defined in:
- lib/active_node/reflection.rb
Overview
Base class for AggregateReflection and AssociationReflection. Objects of AggregateReflection and AssociationReflection are returned by the Reflection::ClassMethods.
MacroReflection
AggregateReflection
AssociationReflection
ThroughReflection
Direct Known Subclasses
Instance Attribute Summary collapse
-
#macro ⇒ Object
readonly
Returns the macro type.
-
#model ⇒ Object
readonly
Returns the value of attribute model.
-
#name ⇒ Object
readonly
Returns the name of the macro.
-
#options ⇒ Object
readonly
Returns the hash of options used for the macro.
-
#scope ⇒ Object
readonly
Returns the value of attribute scope.
Instance Method Summary collapse
-
#==(other_aggregation) ⇒ Object
Returns
true
ifself
andother_aggregation
have the samename
attribute,model
attribute, andother_aggregation
has an options hash assigned to it. -
#class_name ⇒ Object
Returns the class name for the macro.
- #direction ⇒ Object
-
#initialize(macro, name, options, model) ⇒ MacroReflection
constructor
A new instance of MacroReflection.
-
#klass ⇒ Object
Returns the class for the macro.
- #type ⇒ Object
Constructor Details
#initialize(macro, name, options, model) ⇒ MacroReflection
Returns a new instance of MacroReflection.
93 94 95 96 97 98 |
# File 'lib/active_node/reflection.rb', line 93 def initialize(macro, name, , model) @macro = macro @name = name @options = @model = model end |
Instance Attribute Details
#macro ⇒ Object (readonly)
Returns the macro type.
composed_of :balance, class_name: 'Money'
returns :composed_of
has_many :clients
returns :has_many
80 81 82 |
# File 'lib/active_node/reflection.rb', line 80 def macro @macro end |
#model ⇒ Object (readonly)
Returns the value of attribute model.
90 91 92 |
# File 'lib/active_node/reflection.rb', line 90 def model @model end |
#name ⇒ Object (readonly)
Returns the name of the macro.
composed_of :balance, class_name: 'Money'
returns :balance
has_many :clients
returns :clients
74 75 76 |
# File 'lib/active_node/reflection.rb', line 74 def name @name end |
#options ⇒ Object (readonly)
Returns the hash of options used for the macro.
composed_of :balance, class_name: 'Money'
returns { class_name: "Money" }
has_many :clients
returns {}
88 89 90 |
# File 'lib/active_node/reflection.rb', line 88 def @options end |
#scope ⇒ Object (readonly)
Returns the value of attribute scope.
82 83 84 |
# File 'lib/active_node/reflection.rb', line 82 def scope @scope end |
Instance Method Details
#==(other_aggregation) ⇒ Object
Returns true
if self
and other_aggregation
have the same name
attribute, model
attribute, and other_aggregation
has an options hash assigned to it.
126 127 128 129 130 131 132 |
# File 'lib/active_node/reflection.rb', line 126 def ==(other_aggregation) super || other_aggregation.kind_of?(self.class) && name == other_aggregation.name && other_aggregation. && model == other_aggregation.model end |
#class_name ⇒ Object
Returns the class name for the macro.
composed_of :balance, class_name: 'Money'
returns 'Money'
has_many :clients
returns 'Client'
112 113 114 |
# File 'lib/active_node/reflection.rb', line 112 def class_name @class_name ||= ([:class_name] || derive_class_name).to_s end |
#direction ⇒ Object
116 117 118 |
# File 'lib/active_node/reflection.rb', line 116 def direction @direction ||= ([:direction] || :outgoing) end |
#klass ⇒ Object
Returns the class for the macro.
composed_of :balance, class_name: 'Money'
returns the Money class has_many :clients
returns the Client class
104 105 106 |
# File 'lib/active_node/reflection.rb', line 104 def klass @klass ||= class_name.constantize end |
#type ⇒ Object
120 121 122 |
# File 'lib/active_node/reflection.rb', line 120 def type @type ||= ([:type] || derive_type) end |