Class: Alchemy::DeleteElements
- Inherits:
-
Object
- Object
- Alchemy::DeleteElements
- Defined in:
- app/services/alchemy/delete_elements.rb
Defined Under Namespace
Classes: WouldLeaveOrphansError
Instance Attribute Summary collapse
-
#elements ⇒ Object
readonly
Returns the value of attribute elements.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(elements) ⇒ DeleteElements
constructor
A new instance of DeleteElements.
Constructor Details
#initialize(elements) ⇒ DeleteElements
Returns a new instance of DeleteElements.
9 10 11 |
# File 'app/services/alchemy/delete_elements.rb', line 9 def initialize(elements) @elements = elements end |
Instance Attribute Details
#elements ⇒ Object (readonly)
Returns the value of attribute elements.
7 8 9 |
# File 'app/services/alchemy/delete_elements.rb', line 7 def elements @elements end |
Instance Method Details
#call ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'app/services/alchemy/delete_elements.rb', line 13 def call if orphanable_records.present? raise WouldLeaveOrphansError end Gutentag::Tagging.where(taggable: elements).delete_all delete_elements end |