Class: Kalimba::Reflection::AssociationReflection
- Inherits:
-
Object
- Object
- Kalimba::Reflection::AssociationReflection
- Defined in:
- lib/kalimba/reflection.rb
Instance Attribute Summary collapse
-
#macro ⇒ Object
readonly
Returns the value of attribute macro.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Instance Method Summary collapse
-
#class_name ⇒ Object
Returns the class name for the macro.
-
#initialize(name, options = {}) ⇒ AssociationReflection
constructor
A new instance of AssociationReflection.
-
#klass ⇒ Object
Returns the class for the macro.
Constructor Details
#initialize(name, options = {}) ⇒ AssociationReflection
Returns a new instance of AssociationReflection.
23 24 25 26 27 28 29 |
# File 'lib/kalimba/reflection.rb', line 23 def initialize(name, = {}) # only :has_many macro is available for RDF # (Sets, Bags and Unions are thus "downgraded" to it) @macro = :has_many @name = name @options = end |
Instance Attribute Details
#macro ⇒ Object (readonly)
Returns the value of attribute macro.
21 22 23 |
# File 'lib/kalimba/reflection.rb', line 21 def macro @macro end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
21 22 23 |
# File 'lib/kalimba/reflection.rb', line 21 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
21 22 23 |
# File 'lib/kalimba/reflection.rb', line 21 def @options end |
Instance Method Details
#class_name ⇒ Object
Returns the class name for the macro.
composed_of :balance, :class_name => 'Money'
returns 'Money'
has_many :clients
returns 'Client'
43 44 45 |
# File 'lib/kalimba/reflection.rb', line 43 def class_name @class_name ||= ([:class_name] || derive_class_name).to_s 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
35 36 37 |
# File 'lib/kalimba/reflection.rb', line 35 def klass @klass ||= class_name.constantize end |