Module: Millstone::ActiveRecord::Associations::ClassMethods
- Defined in:
- lib/millstone/active_record/associations.rb
Instance Method Summary collapse
- #belongs_to_with_millstone(association_id, options = {}) ⇒ Object
- #has_many_with_millstone(association_id, options = {}, &extension) ⇒ Object
Instance Method Details
#belongs_to_with_millstone(association_id, options = {}) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/millstone/active_record/associations.rb', line 29 def belongs_to_with_millstone(association_id, = {}) with_deleted = .delete :with_deleted belongs_to_without_millstone(association_id, ).tap do if with_deleted reflection = reflect_on_association(association_id) if reflection.[:polymorphic] association_accessor_methods(reflection, Millstone::ActiveRecord::Associations::BelongsToPolymorphicAssociation) else association_accessor_methods(reflection, Millstone::ActiveRecord::Associations::BelongsToAssociation) association_constructor_method(:build, reflection, Millstone::ActiveRecord::Associations::BelongsToAssociation) association_constructor_method(:create, reflection, Millstone::ActiveRecord::Associations::BelongsToAssociation) end end end end |
#has_many_with_millstone(association_id, options = {}, &extension) ⇒ Object
18 19 20 21 22 23 24 25 26 27 |
# File 'lib/millstone/active_record/associations.rb', line 18 def has_many_with_millstone(association_id, = {}, &extension) with_deleted = .delete :with_deleted has_many_without_millstone(association_id, , &extension).tap do reflection = reflect_on_association(association_id) if [:through] and !with_deleted collection_accessor_methods(reflection, Millstone::ActiveRecord::Associations::HasManyThroughWithoutDeletedAssociation) end end end |