Module: LoyalCore::ActsAsTree::InstanceMethods
- Defined in:
- lib/loyal_core/acts/tree.rb
Instance Method Summary collapse
- #children? ⇒ Boolean
-
#tree_ancestor_ids ⇒ Object
祖先.
-
#tree_descendant_ids ⇒ Object
子孙后代.
- #tree_self_and_ancestor_ids ⇒ Object
-
#tree_self_and_descendant_ids ⇒ Object
子孙后代 包括自己.
- #tree_self_and_siblings_ids ⇒ Object
-
#tree_sibling_ids ⇒ Object
同一个父母的孩子.
Instance Method Details
#children? ⇒ Boolean
35 36 37 |
# File 'lib/loyal_core/acts/tree.rb', line 35 def children? self.children_count > 0 end |
#tree_ancestor_ids ⇒ Object
祖先
40 41 42 |
# File 'lib/loyal_core/acts/tree.rb', line 40 def tree_ancestor_ids self.ancestors.map(&:id).uniq.sort end |
#tree_descendant_ids ⇒ Object
子孙后代
58 59 60 |
# File 'lib/loyal_core/acts/tree.rb', line 58 def tree_descendant_ids self.descendants.map(&:id).uniq.sort end |
#tree_self_and_ancestor_ids ⇒ Object
44 45 46 |
# File 'lib/loyal_core/acts/tree.rb', line 44 def tree_self_and_ancestor_ids self.self_and_ancestors.map(&:id).uniq.sort end |
#tree_self_and_descendant_ids ⇒ Object
子孙后代 包括自己
63 64 65 |
# File 'lib/loyal_core/acts/tree.rb', line 63 def tree_self_and_descendant_ids self.self_and_descendants.map(&:id).uniq.sort end |
#tree_self_and_siblings_ids ⇒ Object
53 54 55 |
# File 'lib/loyal_core/acts/tree.rb', line 53 def tree_self_and_siblings_ids self.self_and_siblings_ids.map(&:id).uniq.sort end |
#tree_sibling_ids ⇒ Object
同一个父母的孩子
49 50 51 |
# File 'lib/loyal_core/acts/tree.rb', line 49 def tree_sibling_ids self.siblings.map(&:id).uniq.sort end |