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
81 82 83 |
# File 'lib/ab_admin/concerns/nested_set.rb', line 81 def deep_parent root? ? self : self.parent.try(:deep_parent) end |
#descendants_count ⇒ Object
89 90 91 |
# File 'lib/ab_admin/concerns/nested_set.rb', line 89 def descendants_count (right - left - 1) / 2 end |
#moveable? ⇒ Boolean
85 86 87 |
# File 'lib/ab_admin/concerns/nested_set.rb', line 85 def moveable? new_record? || !root? end |
#nested_opts(collection = nil) ⇒ Object
68 69 70 71 |
# File 'lib/ab_admin/concerns/nested_set.rb', line 68 def nested_opts(collection=nil) collection ||= self.class.all self.class.nested_opts(collection, self) end |
#nested_opts_with_parent(collection = nil) ⇒ Object
63 64 65 66 |
# File 'lib/ab_admin/concerns/nested_set.rb', line 63 def nested_opts_with_parent(collection=nil) collection ||= self.class.all self.class.nested_opts_with_parent(collection, self) end |
#tree_children(tree) ⇒ Object
73 74 75 76 77 78 79 |
# File 'lib/ab_admin/concerns/nested_set.rb', line 73 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
93 94 95 96 |
# File 'lib/ab_admin/concerns/nested_set.rb', line 93 def update_search_index tire.update_index if respond_to?(:tire) true end |