Module: ActiveRecord::Associations::ClassMethods

Defined in:
lib/serialized_attributes/has_references_to.rb

Instance Method Summary collapse

Instance Method Details

#create_has_references_to_reflection(association_id, options, &extension) ⇒ Object



52
53
54
55
56
57
58
# File 'lib/serialized_attributes/has_references_to.rb', line 52

def create_has_references_to_reflection(association_id, options, &extension)
  #options.assert_valid_keys(valid_keys_for_has_many_association)
  options[:extend] = create_extension_modules(association_id, extension, options[:extend])
  reflection = ActiveRecord::Reflection::AssociationReflection.new(:has_many, association_id, options, self)
  write_inheritable_hash :reflections, name => reflection
  reflection
end

#has_references_to(association_id, options = {}, &extension) ⇒ Object



60
61
62
63
64
65
66
# File 'lib/serialized_attributes/has_references_to.rb', line 60

def has_references_to(association_id, options = {}, &extension)
  reflection = create_has_references_to_reflection(association_id, options, &extension)
  configure_dependency_for_has_many(reflection)
  add_association_callbacks(reflection.name, reflection.options)

  collection_accessor_methods(reflection, HasReferencesToAssociation)
end