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.



144
145
146
147
148
149
# 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