Skip to content

Instantly share code, notes, and snippets.

@kennystone
Created October 26, 2011 18:14
Show Gist options
  • Save kennystone/1317209 to your computer and use it in GitHub Desktop.
Save kennystone/1317209 to your computer and use it in GitHub Desktop.
require 'data_mapper'
class Post
include DataMapper::Resource
property :id, Serial
before :save, :categorize
before :update, :categorize
before :create, :categorize
def categorize
puts "W T F"
throw :halt
end
end
DataMapper.setup(:default, "sqlite::memory:")
DataMapper::Logger.new($stdout, :debug)
DataMapper.finalize.auto_migrate!
Post.create!
Post.create!
Post.create!
Post.create!
Post.create!
puts "#{Post.all.map {|a| a.id}.join(' ')} done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment