Class: Kalimba::Reflection::AssociationReflection

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

Instance Attribute Summary collapse

Instance Method Summary collapse

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, options = {})
  # only :has_many macro is available for RDF
  # (Sets, Bags and Unions are thus "downgraded" to it)
  @macro = :has_many
  @name = name
  @options = options
end

Instance Attribute Details

#macroObject (readonly)

Returns the value of attribute macro.



21
22
23
# File 'lib/kalimba/reflection.rb', line 21

def macro
  @macro
end

#nameObject (readonly)

Returns the value of attribute name.



21
22
23
# File 'lib/kalimba/reflection.rb', line 21

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



21
22
23
# File 'lib/kalimba/reflection.rb', line 21

def options
  @options
end

Instance Method Details

#class_nameObject

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 ||= (options[:class_name] || derive_class_name).to_s
end

#klassObject

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