16
17
18
19
20
21
22
23
24
25
26
27
28
|
# File 'lib/association_accessors.rb', line 16
def association_accessor_for(association_name, with_attribute: nil)
mixin = generated_association_methods
reflection = reflect_on_association association_name
with_attribute ||= AssociationAccessors.default_attribute
raise ArgumentError, 'missing keyword: with_attribute' if with_attribute.nil?
if reflection.collection?
CollectionAssociation.define_association_methods mixin, reflection, with_attribute
else
SingularAssociation.define_association_methods mixin, reflection, with_attribute
end
end
|