module Parentry::Strategy::Array::InstanceMethods

Public Instance Methods

ancestor_conditions() click to toggle source
# File lib/parentry/strategy/array/instance_methods.rb, line 31
def ancestor_conditions
  ["#{parentry_column} <@ ARRAY[?]", parentry]
end
cascade_parentry() click to toggle source
# File lib/parentry/strategy/array/instance_methods.rb, line 15
def cascade_parentry
  old_path, new_path = saved_changes[parentry_column]
  parentry_scope.where(
    ["#{parentry_column} @> ARRAY[:tree] AND id != :id", tree: old_path, id: id]
  ).update_all(
    [
      "#{parentry_column} = array_cat(ARRAY[?], #{parentry_column}[?:array_length(#{parentry_column}, 1)])",
      new_path, old_path.size + 1
    ]
  )
end
compute_parentry() click to toggle source
# File lib/parentry/strategy/array/instance_methods.rb, line 9
def compute_parentry
  return [] unless persisted?

  parent.present? ? parent.parentry + [id] : [id]
end
parse_parentry(input = parentry) click to toggle source
# File lib/parentry/strategy/array/instance_methods.rb, line 5
def parse_parentry(input = parentry)
  input
end
subtree_conditions() click to toggle source
# File lib/parentry/strategy/array/instance_methods.rb, line 27
def subtree_conditions
  ["#{parentry_column} @> ARRAY[?]", parentry]
end