Skip to content

Instantly share code, notes, and snippets.

@solnic
Created March 25, 2015 13:27
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • 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
@pnomolos
Copy link

@solnic Does the ROM example need to be run on master? I'm trying to get it working and not having much luck (also converting to SQLite so it's a self-contained example).

@solnic
Copy link
Author

solnic commented Mar 25, 2015

doesn't matter, you can use released gems.

@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