I started out with this - using a clean db:
require 'rubygems'
require 'strokedb'
FileUtils.rm_rf 'test.strokedb' # cleanup the database
StrokeDB::Config.build :default => true, :base_path => 'test.strokedb'
include StrokeDB
Node = Meta.new do
validates_presence_of :label
# on_initialization do |node|
# node.nodes = [] unless node[:nodes]
# end
end
root = Node.named('root', :label => 'root')
# root = Node.named('root')
p Node.find
then I comment-out the db-rebuild steps:
require 'rubygems'
require 'strokedb'
# FileUtils.rm_rf 'test.strokedb' # cleanup the database
StrokeDB::Config.build :default => true, :base_path => 'test.strokedb'
include StrokeDB
Node = Meta.new do
validates_presence_of :label
# on_initialization do |node|
# node.nodes = [] unless node[:nodes]
# end
end
# root = Node.named('root', :label => 'root')
root = Node.named('root')
p Node.find
Everything is still fine. Then I uncomment the on_initialization code block:
require 'rubygems'
require 'strokedb'
# FileUtils.rm_rf 'test.strokedb' # cleanup the database
StrokeDB::Config.build :default => true, :base_path => 'test.strokedb'
include StrokeDB
Node = Meta.new do
validates_presence_of :label
on_initialization do |node|
node.nodes = [] unless node[:nodes]
end
end
# root = Node.named('root', :label => 'root')
root = Node.named('root')
p Node.find
This runs very long, probably in an infinite loop (didn't wait for it to finish after 30 secs).