Module: ParanoidFu::Associations

Defined in:
lib/paranoid_fu/associations.rb

Instance Method Summary collapse

Instance Method Details

#belongs_to(association_id, options = {}) ⇒ Object

Options

:without_deleted

Don’t load associated object if it’s deleted.



6
7
8
9
10
11
# File 'lib/paranoid_fu/associations.rb', line 6

def belongs_to(association_id, options = {})
  without_deleted = options.delete :without_deleted
  returning super(association_id, options) do
    restore_without_deleted(association_id, without_deleted)
  end
end

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



27
28
29
30
31
32
# File 'lib/paranoid_fu/associations.rb', line 27

def has_and_belongs_to_many(association_id, options = {}, &extension)
  without_deleted = options.delete :without_deleted
  returning super(association_id, options, &extension) do
    restore_without_deleted(association_id, without_deleted)
  end
end

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



20
21
22
23
24
25
# File 'lib/paranoid_fu/associations.rb', line 20

def has_many(association_id, options = {}, &extension)
  without_deleted = options.delete :without_deleted
  returning super(association_id, options, &extension) do
    restore_without_deleted(association_id, without_deleted)
  end
end

#has_one(association_id, options = {}) ⇒ Object



13
14
15
16
17
18
# File 'lib/paranoid_fu/associations.rb', line 13

def has_one(association_id, options = {})
  without_deleted = options.delete :without_deleted
  returning super(association_id, options) do
    restore_without_deleted(association_id, without_deleted)
  end
end