Module: Ancestry::MaterializedPath2
Overview
store ancestry as /grandparent_id/parent_id/ root: a=/,id=1 children=#a#id/% == /1/% 3: a=/1/2/,id=3 children=#a#id/% == /1/2/3/%
Defined Under Namespace
Modules: InstanceMethods
Class Method Summary
collapse
Instance Method Summary
collapse
#ancestors_of, #children_of, #descendant_before_save_conditions, #descendant_conditions, #descendants_of, #inpath_of, #ordered_by_ancestry_and, #path_of, #roots, #siblings_of, #subtree_of
Instance Method Details
#ancestry_root ⇒ Object
27
28
29
|
# File 'lib/ancestry/materialized_path2.rb', line 27
def ancestry_root
ancestry_delimiter
end
|
#descendants_by_ancestry(ancestry) ⇒ Object
23
24
25
|
# File 'lib/ancestry/materialized_path2.rb', line 23
def descendants_by_ancestry(ancestry)
arel_table[ancestry_column].matches("#{ancestry}%", nil, true)
end
|
#indirects_of(object) ⇒ Object
13
14
15
16
17
|
# File 'lib/ancestry/materialized_path2.rb', line 13
def indirects_of(object)
t = arel_table
node = to_node(object)
where(t[ancestry_column].matches("#{node.child_ancestry}%#{ancestry_delimiter}%", nil, true))
end
|
#ordered_by_ancestry(order = nil) ⇒ Object
19
20
21
|
# File 'lib/ancestry/materialized_path2.rb', line 19
def ordered_by_ancestry(order = nil)
reorder(Arel::Nodes::Ascending.new(arel_table[ancestry_column]), order)
end
|