7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/associations.rb', line 7
def has(cardinality, name, *args)
opts = args.
if interface = opts.delete(:polymorphically)
child_model_name = opts.fetch(:class_name, Extlib::Inflection.classify(name))
child_klass = Extlib::Inflection.constantize(child_model_name)
belongs_to_name = Extlib::Inflection.underscore(Extlib::Inflection.demodulize(self.name))
has_without_polymorphism cardinality, name, :child_key => [:"#{interface}_id"], :"#{interface}_class" => self
child_klass.belongs_to :"#{belongs_to_name}", :child_key => [:"#{interface}_id"], :"#{interface}_class" => self
else
has_without_polymorphism(cardinality, name, *(args + [opts]))
end
end
|