Module: AbAdmin::Concerns::NestedSet
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/ab_admin/concerns/nested_set.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #deep_parent ⇒ Object
- #descendants_count ⇒ Object
- #moveable? ⇒ Boolean
- #nested_opts(collection = nil) ⇒ Object
- #nested_opts_with_parent(collection = nil) ⇒ Object
- #tree_children(tree) ⇒ Object
- #update_search_index ⇒ Object
Instance Method Details
#deep_parent ⇒ Object
80 81 82 |
# File 'lib/ab_admin/concerns/nested_set.rb', line 80 def deep_parent root? ? self : self.parent.try(:deep_parent) end |
#descendants_count ⇒ Object
88 89 90 |
# File 'lib/ab_admin/concerns/nested_set.rb', line 88 def descendants_count (right - left - 1) / 2 end |
#moveable? ⇒ Boolean
84 85 86 |
# File 'lib/ab_admin/concerns/nested_set.rb', line 84 def moveable? new_record? || !root? end |
#nested_opts(collection = nil) ⇒ Object
67 68 69 70 |
# File 'lib/ab_admin/concerns/nested_set.rb', line 67 def nested_opts(collection=nil) collection ||= self.class.all self.class.nested_opts(collection, self) end |
#nested_opts_with_parent(collection = nil) ⇒ Object
62 63 64 65 |
# File 'lib/ab_admin/concerns/nested_set.rb', line 62 def nested_opts_with_parent(collection=nil) collection ||= self.class.all self.class.nested_opts_with_parent(collection, self) end |
#tree_children(tree) ⇒ Object
72 73 74 75 76 77 78 |
# File 'lib/ab_admin/concerns/nested_set.rb', line 72 def tree_children(tree) return unless tree[self.id] self.cached_children = tree[self.id] self.cached_children.each do |r| r.tree_children(tree) end end |
#update_search_index ⇒ Object
92 93 94 95 |
# File 'lib/ab_admin/concerns/nested_set.rb', line 92 def update_search_index tire.update_index if respond_to?(:tire) true end |