Module: Sequel::Plugins::Tree::SingleRoot::InstanceMethods

Defined in:
lib/sequel/plugins/tree.rb

Instance Method Summary collapse

Instance Method Details

#before_saveObject

Hook that prevents a second root from being created.



176
177
178
179
180
181
# File 'lib/sequel/plugins/tree.rb', line 176

def before_save
  if possible_root? && (root = model.root) && pk != root.pk
    raise TreeMultipleRootError, "there is already a root #{model.name} defined"
  end
  super
end