module Parentry::Strategy::Ltree::InstanceMethods
Public Instance Methods
ancestor_conditions()
click to toggle source
# File lib/parentry/strategy/ltree/instance_methods.rb, line 29 def ancestor_conditions ["#{parentry_column} @> ?", parentry] end
cascade_parentry()
click to toggle source
# File lib/parentry/strategy/ltree/instance_methods.rb, line 13 def cascade_parentry old_path, new_path = saved_changes[parentry_column] parentry_scope.where( ["#{parentry_column} <@ :tree AND id != :id", tree: old_path, id: id] ).update_all( [ "#{parentry_column} = :new_path || subpath(#{parentry_column}, nlevel(:old_path))", new_path: new_path, old_path: old_path ] ) end
compute_parentry()
click to toggle source
# File lib/parentry/strategy/ltree/instance_methods.rb, line 9 def compute_parentry parent.present? ? "#{parent.parentry}.#{id}" : id.to_s end
parse_parentry(input = parentry)
click to toggle source
# File lib/parentry/strategy/ltree/instance_methods.rb, line 5 def parse_parentry(input = parentry) input.to_s.split('.').map(&:to_i) end
subtree_conditions()
click to toggle source
# File lib/parentry/strategy/ltree/instance_methods.rb, line 25 def subtree_conditions ["#{parentry_column} <@ ?", parentry] end