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.


153
154
155
156
157
158
# File 'lib/sequel/plugins/tree.rb', line 153

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