include DataMapper property :id, Serial property :name, String, :nullable => false has n, :commits, :model => "Integrity::Commit" end include DataMapper property :id, Serial property :identifier, String, :nullable => false has 1, :build, :model => "Integrity::Build" belongs_to :project, :model => "Integrity::Project", :child_key => [:project_id] end include DataMapper property :id, Serial property :output, Text, :default => "" belongs_to :commit, :model => "Integrity::Commit", :child_key => [:commit_id] end end DataMapper(STDOUT, :debug) DataMapper(:default, "sqlite3::memory:") DataMapper project = Integrity(:name => "My Project") 100 { project << Integrity(:identifier => "f59dd24", :build => Integrity(:output => /[:sentence:]/)) project } idx = 0 Integrity(1) do |c| idx += 1 puts "idx = , " end # performs 100 SELECTs and ends with a nil access # ~ (0.000030) SELECT "id", "commit_id" FROM "integrity_builds" WHERE "commit_id" = 98 ORDER BY "id" LIMIT 1 # ~ (0.000030) SELECT "id", "output" FROM "integrity_builds" WHERE "commit_id" = 98 ORDER BY "id" LIMIT 1 # idx = 98, Tricarpellary smalt potorous superextend nonconspirator fork bookdom brasque voltameter concernment gentleship aeronat # DataMapper::Associations::OneToMany::Collection#build is deprecated, use DataMapper::Associations::OneToMany::Collection#new instead (/opt/local/lib/ruby/gems/1.8/gems/dm-core-0.10.0/lib/dm-core/associations/one_to_many.rb:152:in `send') # ~ (0.000029) SELECT "id", "commit_id" FROM "integrity_builds" WHERE "commit_id" = 99 ORDER BY "id" LIMIT 1 # ~ (0.000029) SELECT "id", "output" FROM "integrity_builds" WHERE "commit_id" = 99 ORDER BY "id" LIMIT 1 # idx = 99, Gavel insatiate micropia sacerdotalize talloel saltpetrous institutionalism outweave notch tum permalloy malodorousness equal paramount histaminase sucivilized # DataMapper::Associations::OneToMany::Collection#build is deprecated, use DataMapper::Associations::OneToMany::Collection#new instead (/opt/local/lib/ruby/gems/1.8/gems/dm-core-0.10.0/lib/dm-core/associations/one_to_many.rb:152:in `send') # ~ (0.000036) SELECT "id", "commit_id" FROM "integrity_builds" WHERE "commit_id" = 100 ORDER BY "id" LIMIT 1 # ~ (0.000030) SELECT "id", "output" FROM "integrity_builds" WHERE "commit_id" = 100 ORDER BY "id" LIMIT 1 # idx = 100, Tetradic uninflammable lionet phthiocol unhumble resatisfy tumultuation # sr.rb:52: undefined method `output' for nil:NilClass (NoMethodError) # from /opt/local/lib/ruby/gems/1.8/gems/extlib-0.9.13/lib/extlib/lazy_array.rb:458:in `each' # from /opt/local/lib/ruby/gems/1.8/gems/extlib-0.9.13/lib/extlib/lazy_array.rb:458:in `each' # from sr.rb:50
