module HideAncestry::InstanceMethods
Public Instance Methods
changes_applied()
click to toggle source
Monkeypatching ActiveModel::Dirty method to correct work of previous_changes in model
# File lib/hide_ancestry/instance_methods.rb, line 88 def changes_applied @previously_changed = @record_changes @changed_attributes = ActiveSupport::HashWithIndifferentAccess.new end
find_first_real_parent()
click to toggle source
# File lib/hide_ancestry/instance_methods.rb, line 80 def find_first_real_parent parent_usr = self.class.find_by id: old_parent_id return parent unless parent_usr parent_usr.hidden? ? parent_usr.find_first_real_parent : parent_usr end
first_hiding?()
click to toggle source
# File lib/hide_ancestry/instance_methods.rb, line 14 def first_hiding? old_parent_changes = previous_changes['old_parent_id'] return unless old_parent_changes old_parent_changes.first.nil? end
hide()
click to toggle source
# File lib/hide_ancestry/instance_methods.rb, line 3 def hide return not_valid unless valid? HideAncestry::ModelManage::Hide.call(self) end
hide_ancestry_ids()
click to toggle source
# File lib/hide_ancestry/instance_methods.rb, line 24 def hide_ancestry_ids hide_ancestry.split('/').map(&:to_i) if hide_ancestry end
restore()
click to toggle source
# File lib/hide_ancestry/instance_methods.rb, line 8 def restore return not_valid unless valid? return already_restored unless public_send(hidden_column) == true HideAncestry::ModelManage::Restore.call(self) end