Module: MongoMapper::Acts::Tree::Fields
- Defined in:
- lib/mongo_mapper_acts_as_tree.rb
Instance Method Summary collapse
- #depth_field ⇒ Object
- #parent_id_field ⇒ Object
- #path_field ⇒ Object
-
#search_class ⇒ Object
When added as an option to acts_as_tree, search class will be used as the base from which to find tree objects.
- #tree_order ⇒ Object
Instance Method Details
#depth_field ⇒ Object
173 174 175 |
# File 'lib/mongo_mapper_acts_as_tree.rb', line 173 def depth_field [:depth_field] end |
#parent_id_field ⇒ Object
165 166 167 |
# File 'lib/mongo_mapper_acts_as_tree.rb', line 165 def parent_id_field [:parent_id_field] end |
#path_field ⇒ Object
169 170 171 |
# File 'lib/mongo_mapper_acts_as_tree.rb', line 169 def path_field [:path_field] end |
#search_class ⇒ Object
When added as an option to acts_as_tree, search class will be used as the base from which to find tree objects. This is handy should you have a tree of objects that are of different types, but might be related through single table inheritance.
acts_as_tree :search_class => Shape
In the above example, you could have a working tree ofShape, Circle and Square types (assuming Circle and Square were subclasses of Shape). If you want to do the same thing and you don’t provide search_class, nesting mixed types will not work.
The default is self.class
192 193 194 |
# File 'lib/mongo_mapper_acts_as_tree.rb', line 192 def search_class [:search_class] or self.class end |
#tree_order ⇒ Object
177 178 179 |
# File 'lib/mongo_mapper_acts_as_tree.rb', line 177 def tree_order [:order] or "" end |