Skip to content

Instantly share code, notes, and snippets.

@pathsny
Created April 30, 2010 16:04
Show Gist options
  • Save pathsny/385405 to your computer and use it in GitHub Desktop.
Save pathsny/385405 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'dm-core'
class Foo
include DataMapper::Resource
property :id, Serial
property :foo, Integer
property :bar, String
after :create do |status|
self.update(:bar => "hello#{self.foo}#{self.id}")
end
end
DataMapper.setup(:default, "sqlite3::memory:")
DataMapper.auto_migrate!
Foo.create(:foo => 21)
puts Foo.first.foo
puts Foo.first.id
puts Foo.first.bar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment