Class: Enumerations::Reflection

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, options = {}) ⇒ Reflection

Returns a new instance of Reflection.



5
6
7
8
# File 'lib/enumerations/reflection.rb', line 5

def initialize(name, options = {})
  @name = name
  @options = options
end

Instance Attribute Details

#nameObject (readonly)

Returns the value of attribute name.



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

def name
  @name
end

#optionsObject (readonly)

Returns the value of attribute options.



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

def options
  @options
end

Instance Method Details

#class_nameObject



10
11
12
# File 'lib/enumerations/reflection.rb', line 10

def class_name
  @class_name ||= (options[:class_name] || name).to_s.camelize
end

#enumerator_classObject



18
19
20
# File 'lib/enumerations/reflection.rb', line 18

def enumerator_class
  @enumerator_class ||= class_name.constantize
end

#foreign_keyObject



14
15
16
# File 'lib/enumerations/reflection.rb', line 14

def foreign_key
  @foreign_key ||= (options[:foreign_key] || default_foreign_key_name).to_sym
end