Class: SoftDeletion::Dependency
- Inherits:
-
Object
- Object
- SoftDeletion::Dependency
- Defined in:
- lib/soft_deletion/dependency.rb
Instance Attribute Summary collapse
-
#association_name ⇒ Object
readonly
Returns the value of attribute association_name.
-
#record ⇒ Object
readonly
Returns the value of attribute record.
Instance Method Summary collapse
-
#initialize(record, association_name) ⇒ Dependency
constructor
A new instance of Dependency.
- #soft_delete! ⇒ Object
- #soft_undelete! ⇒ Object
Constructor Details
#initialize(record, association_name) ⇒ Dependency
Returns a new instance of Dependency.
5 6 7 8 |
# File 'lib/soft_deletion/dependency.rb', line 5 def initialize(record, association_name) @record = record @association_name = association_name end |
Instance Attribute Details
#association_name ⇒ Object (readonly)
Returns the value of attribute association_name.
3 4 5 |
# File 'lib/soft_deletion/dependency.rb', line 3 def association_name @association_name end |
#record ⇒ Object (readonly)
Returns the value of attribute record.
3 4 5 |
# File 'lib/soft_deletion/dependency.rb', line 3 def record @record end |
Instance Method Details
#soft_delete! ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/soft_deletion/dependency.rb', line 10 def soft_delete! return unless can_soft_delete? if nullify? nullify_dependencies else dependencies.each(&:soft_delete!) end end |
#soft_undelete! ⇒ Object
20 21 22 23 24 25 26 |
# File 'lib/soft_deletion/dependency.rb', line 20 def soft_undelete! return unless can_soft_delete? klass.with_deleted do dependencies.each(&:soft_undelete!) end end |