Module: NumberedRelationships::ConstructorFinder

Defined in:
lib/numbered_relationships/constructor_finder.rb

Class Method Summary collapse

Class Method Details

.find(options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
# File 'lib/numbered_relationships/constructor_finder.rb', line 7

def self.find(options={})
  reflection = options[:reflection]
  case reflection.macro
  when :has_and_belongs_to_many
    HasAndBelongsToManyConstructor.new(options)
  when :has_many
    thru = reflection.options[:through] if reflection
    return HasManyConstructor.new(options) unless thru
    HasManyThroughConstructor.new(options)
  end
end