Skip to content

Instantly share code, notes, and snippets.

require 'rom'
require 'rom-repository'
rom = ROM.container(:sql, 'sqlite::memory') do |c|
c.default.create_table(:users) do
primary_key :id
column :name, String
end
c.default.create_table(:tasks) do
require 'rom-sql'
require 'rom-repository'
rom = ROM.container(:sql, 'sqlite::memory') do |c|
c.gateways[:default].create_table :things do
primary_key :id
column :first_id, Integer
column :second_id, Integer
column :name, String
end
#!/usr/bin/env ruby
require "rom-sql"
require "rom-repository"
require "dry-types"
module Relations
class Users < ROM::Relation[:sql]
schema(:users, infer: true)
end
#!/usr/bin/env ruby
require "rom-sql"
require "rom-repository"
require "dry-types"
module Relations
class Charts < ROM::Relation[:sql]
schema(:charts, infer: true) do
associations do
require 'byebug'
require 'rom-sql'
rom = ROM.container(:sql, 'sqlite::memory') do |conf|
conf.gateways[:default].create_table(:users) do
primary_key :id
column :name, String
column :created_at, Time
column :updated_at, Time
end
require 'byebug'
require 'rom-sql'
rom = ROM.container(:sql, 'sqlite::memory') do |conf|
conf.gateways[:default].create_table(:users) do
primary_key :id
column :name, String
column :created_at, Time
column :updated_at, Time
end
require 'dry-validation'
schema = Dry::Validation.Schema do
configure do
def self.messages
super.merge(en: { errors: { foo: 'either a or b can be filled' } })
end
end
required(:a).maybe

Keybase proof

I hereby claim:

  • I am solnic on github.
  • I am solnic (https://keybase.io/solnic) on keybase.
  • I have a public key whose fingerprint is 7ADB C08A 02C3 8088 9FB0 7DB7 66BF 2FDA 7BA0 F29C

To claim this, I am signing this object:

@solnic
solnic / result.txt
Last active June 28, 2016 12:49
time_math2 vs active-support core ext benchmark
Warming up --------------------------------------
time math 2.101k i/100ms
active support 1.619k i/100ms
Calculating -------------------------------------
time math 21.870k (± 4.1%) i/s - 109.252k in 5.003726s
active support 16.309k (± 4.8%) i/s - 82.569k in 5.074850s
Comparison:
time math: 21869.9 i/s
active support: 16308.7 i/s - 1.34x slower
require 'dry-validation'
SCHEMA = Dry::Validation.Schema do
configure do
config.input_processor = :sanitizer
def self.messages
Dry::Validation::Messages.default.merge(en: { errors: { unique?: "oops not unique" }})
end