Module: HasHierarchy::OrmAdapter::ActiveRecord
- Defined in:
- lib/has_hierarchy/orm_adapter/active_record.rb
Instance Method Summary collapse
Instance Method Details
#ancestors ⇒ Object
4 5 6 |
# File 'lib/has_hierarchy/orm_adapter/active_record.rb', line 4 def ancestors tree_scope.where(path_part_column => path_parts) end |
#descendants ⇒ Object
20 21 22 |
# File 'lib/has_hierarchy/orm_adapter/active_record.rb', line 20 def descendants tree_scope.where(descendants_conditions) end |
#siblings ⇒ Object
8 9 10 11 12 |
# File 'lib/has_hierarchy/orm_adapter/active_record.rb', line 8 def siblings t = self.class.arel_table tree_scope.where(t[:parent_id].eq(parent_id).and(t[:id].not_eq(id))) end |
#subtree ⇒ Object
14 15 16 17 18 |
# File 'lib/has_hierarchy/orm_adapter/active_record.rb', line 14 def subtree t = self.class.arel_table tree_scope.where(t[:id].eq(id).or(descendants_conditions)) end |