Sha256: f8da1d7c05bd753f27aa1ac424d72b6aafc4e96f60ca971b4d610a597417bf88
Contents?: true
Size: 934 Bytes
Versions: 1
Compression:
Stored size: 934 Bytes
Contents
module Parentry module Strategy module Ltree module InstanceMethods def parse_parentry(input = parentry) input.to_s.split('.').map(&:to_i) end def compute_parentry parent.present? ? "#{parent.parentry}.#{id}" : id.to_s end 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 def subtree_conditions ["#{parentry_column} <@ ?", parentry] end def ancestor_conditions ["#{parentry_column} @> ?", parentry] end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
parentry-1.4.0 | lib/parentry/strategy/ltree/instance_methods.rb |