Skip to content

Instantly share code, notes, and snippets.

@solnic
Created March 25, 2015 13:27
Show Gist options
  • Save solnic/5047c4972d7d5ad1ff8c to your computer and use it in GitHub Desktop.
Save solnic/5047c4972d7d5ad1ff8c to your computer and use it in GitHub Desktop.
ROM/AR "create" operation profiling
require 'active_record'
require 'hotch'
ActiveRecord::Base.establish_connection('postgresql://localhost/rom')
class User < ActiveRecord::Base
end
User.delete_all
Hotch() do
User.create(name: 'Jane Doe', email: 'jane@doe.org', age: 21)
end
require 'rom-sql'
require 'hotch'
ROM.setup(:sql, 'postgres://localhost/rom')
ROM.commands(:users) do
define(:create) do
result :one
end
end
rom = ROM.finalize.env
create_user = rom.command(:users).create
Hotch() do
create_user.call(name: 'Jane Doe', email: 'jane@doe.org', age: 21)
end
@pushcx
Copy link

pushcx commented Mar 25, 2015

For anyone who finds this and wants to tinker, here's the setup:

$ createdb rom;
$ psql rom
[local] username@rom=# create table users (name varchar, email varchar, age int);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment