Module: ProtectedParent::InstanceMethods
- Defined in:
- lib/protected_parent/protected_parent_of.rb
Instance Method Summary collapse
- #a_plural(child) ⇒ Object
-
#protected? ⇒ Boolean
The inverse of removable?, is this instance protected from deletion?.
- #protected_children ⇒ Object
-
#removable? ⇒ Boolean
Can the instance be deleted?.
Instance Method Details
#a_plural(child) ⇒ Object
52 53 54 |
# File 'lib/protected_parent/protected_parent_of.rb', line 52 def a_plural(child) child.pluralize == child end |
#protected? ⇒ Boolean
The inverse of removable?, is this instance protected from deletion?
48 49 50 |
# File 'lib/protected_parent/protected_parent_of.rb', line 48 def protected? !removable? end |
#protected_children ⇒ Object
37 38 39 40 41 42 43 44 45 |
# File 'lib/protected_parent/protected_parent_of.rb', line 37 def protected_children self.class.children_of_protected_parent.select do |child| if a_plural child child unless send(child).count.zero? else child unless send(child).nil? end end end |
#removable? ⇒ Boolean
Can the instance be deleted?
33 34 35 |
# File 'lib/protected_parent/protected_parent_of.rb', line 33 def removable? self.class.softly_protected || protected_children.empty? end |