module Sequel::Plugins::Tree::SingleRoot::InstanceMethods

  1. lib/sequel/plugins/tree.rb
Parent: SingleRoot

Methods

Public Instance

  1. before_save

Public Instance methods

before_save ()

Hook that prevents a second root from being created.

[show source]
# File lib/sequel/plugins/tree.rb, line 144
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