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
- #tree_children(tree) ⇒ Object
- #update_search_index ⇒ Object
Instance Method Details
#deep_parent ⇒ Object
59 60 61 |
# File 'lib/ab_admin/concerns/nested_set.rb', line 59 def deep_parent root? ? self : self.parent.try(:deep_parent) end |
#descendants_count ⇒ Object
67 68 69 |
# File 'lib/ab_admin/concerns/nested_set.rb', line 67 def descendants_count (right - left - 1) / 2 end |
#moveable? ⇒ Boolean
63 64 65 |
# File 'lib/ab_admin/concerns/nested_set.rb', line 63 def moveable? new_record? || !root? end |
#nested_opts(collection = nil) ⇒ Object
46 47 48 49 |
# File 'lib/ab_admin/concerns/nested_set.rb', line 46 def nested_opts(collection=nil) collection ||= self.class.all self.class.nested_opts(collection, self) end |
#tree_children(tree) ⇒ Object
51 52 53 54 55 56 57 |
# File 'lib/ab_admin/concerns/nested_set.rb', line 51 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
71 72 73 74 |
# File 'lib/ab_admin/concerns/nested_set.rb', line 71 def update_search_index tire.update_index if respond_to?(:tire) true end |