Module: MongoTree::Strategies::AncestorArray::InstanceMethods
- Defined in:
- lib/mongo_tree/strategies/ancestor_array.rb
Instance Method Summary collapse
Instance Method Details
#ancestors ⇒ Object
44 45 46 |
# File 'lib/mongo_tree/strategies/ancestor_array.rb', line 44 def ancestors self.ancestor_ids.map{ |id| self.class.first(path_attribute => id) } end |
#depth ⇒ Object
36 37 38 |
# File 'lib/mongo_tree/strategies/ancestor_array.rb', line 36 def depth ancestor_ids.length end |
#descendants ⇒ Object
48 49 50 |
# File 'lib/mongo_tree/strategies/ancestor_array.rb', line 48 def descendants self.class.all(:ancestor_ids.all => self.ancestor_ids << self.send(path_attribute)) end |
#root ⇒ Object
32 33 34 |
# File 'lib/mongo_tree/strategies/ancestor_array.rb', line 32 def root self.class.first(path_attribute => self.ancestor_ids.first) end |
#siblings ⇒ Object
40 41 42 |
# File 'lib/mongo_tree/strategies/ancestor_array.rb', line 40 def siblings self.class.all(:parent_id => self.parent_id, path_attribute.ne => self.send(path_attribute)) end |