Class: Morpheus::Reflection
- Inherits:
-
Object
- Object
- Morpheus::Reflection
- Defined in:
- lib/morpheus/reflection.rb
Instance Attribute Summary collapse
-
#class_name ⇒ Object
readonly
Returns the value of attribute class_name.
-
#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
- #build_association(*options) ⇒ Object
-
#initialize(macro, name, options = {}) ⇒ Reflection
constructor
A new instance of Reflection.
- #klass ⇒ Object
Constructor Details
#initialize(macro, name, options = {}) ⇒ Reflection
Returns a new instance of Reflection.
5 6 7 8 9 10 |
# File 'lib/morpheus/reflection.rb', line 5 def initialize(macro, name, = {}) @macro = macro @name = name @options = @class_name = (@options[:class_name] || @name).to_s.singularize.camelize end |
Instance Attribute Details
#class_name ⇒ Object (readonly)
Returns the value of attribute class_name.
3 4 5 |
# File 'lib/morpheus/reflection.rb', line 3 def class_name @class_name end |
#macro ⇒ Object (readonly)
Returns the value of attribute macro.
3 4 5 |
# File 'lib/morpheus/reflection.rb', line 3 def macro @macro end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/morpheus/reflection.rb', line 3 def name @name end |
#options ⇒ Object (readonly)
Returns the value of attribute options.
3 4 5 |
# File 'lib/morpheus/reflection.rb', line 3 def @options end |
Instance Method Details
#build_association(*options) ⇒ Object
16 17 18 |
# File 'lib/morpheus/reflection.rb', line 16 def build_association(*) klass.new(*) end |
#klass ⇒ Object
12 13 14 |
# File 'lib/morpheus/reflection.rb', line 12 def klass @klass ||= @class_name.constantize end |