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

Defined in:
lib/mongo_mapper_acts_as_tree.rb

Instance Method Summary collapse

Instance Method Details

#depth_fieldObject



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

def depth_field
  acts_as_tree_options[:depth_field]
end

#parent_id_fieldObject



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

def parent_id_field
  acts_as_tree_options[:parent_id_field]
end

#path_fieldObject



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

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



192
193
194
# File 'lib/mongo_mapper_acts_as_tree.rb', line 192

def search_class
  acts_as_tree_options[:search_class] or self.class
end

#tree_orderObject



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

def tree_order
  acts_as_tree_options[:order] or ""
end