Class: Morpheus::Reflection

Inherits:
Object
  • Object
show all
Defined in:
lib/morpheus/reflection.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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, options = {})
  @macro      = macro
  @name       = name
  @options    = options
  @class_name = (@options[:class_name] || @name).to_s.singularize.camelize
end

Instance Attribute Details

#class_nameObject (readonly)

Returns the value of attribute class_name.



3
4
5
# File 'lib/morpheus/reflection.rb', line 3

def class_name
  @class_name
end

#macroObject (readonly)

Returns the value of attribute macro.



3
4
5
# File 'lib/morpheus/reflection.rb', line 3

def macro
  @macro
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/morpheus/reflection.rb', line 3

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



3
4
5
# File 'lib/morpheus/reflection.rb', line 3

def options
  @options
end

Instance Method Details

#build_association(*options) ⇒ Object



16
17
18
# File 'lib/morpheus/reflection.rb', line 16

def build_association(*options)
  klass.new(*options)
end

#klassObject



12
13
14
# File 'lib/morpheus/reflection.rb', line 12

def klass
  @klass ||= @class_name.constantize
end