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
172 173 174 |
# File 'lib/mongo_mapper_acts_as_tree.rb', line 172 def depth_field [:depth_field] end |
#parent_id_field ⇒ Object
164 165 166 |
# File 'lib/mongo_mapper_acts_as_tree.rb', line 164 def parent_id_field [:parent_id_field] end |
#path_field ⇒ Object
168 169 170 |
# File 'lib/mongo_mapper_acts_as_tree.rb', line 168 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
191 192 193 |
# File 'lib/mongo_mapper_acts_as_tree.rb', line 191 def search_class [:search_class] or self.class end |
#tree_order ⇒ Object
176 177 178 |
# File 'lib/mongo_mapper_acts_as_tree.rb', line 176 def tree_order [:order] or "" end |