Module: MongoMapper::Acts::Tree::Fields

Defined in:
lib/mongo_mapper_acts_as_tree.rb

Instance Method Summary collapse

Instance Method Details

#depth_fieldObject



172
173
174
# File 'lib/mongo_mapper_acts_as_tree.rb', line 172

def depth_field
  acts_as_tree_options[:depth_field]
end

#parent_id_fieldObject



164
165
166
# File 'lib/mongo_mapper_acts_as_tree.rb', line 164

def parent_id_field
  acts_as_tree_options[:parent_id_field]
end

#path_fieldObject



168
169
170
# File 'lib/mongo_mapper_acts_as_tree.rb', line 168

def path_field
  acts_as_tree_options[:path_field]
end

#search_classObject

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
  acts_as_tree_options[:search_class] or self.class
end

#tree_orderObject



176
177
178
# File 'lib/mongo_mapper_acts_as_tree.rb', line 176

def tree_order
  acts_as_tree_options[:order] or ""
end