This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'dry-data' | |
require 'dry/data/type/constrained' | |
require 'active_record' | |
require 'benchmark/ips' | |
ActiveRecord::Base.establish_connection(adapter: "sqlite3", database: ":memory:") | |
ActiveRecord::Schema.define do | |
create_table :users do |table| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Calculating ------------------------------------- | |
ActiveModel::Validations | |
134.000 i/100ms | |
dry-validation 2.145k i/100ms | |
------------------------------------------------- | |
ActiveModel::Validations | |
1.499k (±11.5%) i/s - 7.504k | |
dry-validation 22.300k (±10.5%) i/s - 111.540k | |
Comparison: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'benchmark/ips' | |
require 'active_model' | |
require 'virtus' | |
require 'dry-validation' | |
require 'dry/validation/schema/form' | |
class User | |
include ActiveModel::Validations | |
include Virtus.model |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I, [2015-11-11T18:21:57.978652 #52590] INFO -- : (0.000162s) CREATE TABLE `users` (`id` integer NOT NULL PRIMARY KEY AUTOINCREMENT, `name` varchar(255)) | |
I, [2015-11-11T18:21:57.978842 #52590] INFO -- : (0.000069s) CREATE TABLE `groups` (`id` integer NOT NULL PRIMARY KEY AUTOINCREMENT, `name` varchar(255)) | |
I, [2015-11-11T18:21:57.979020 #52590] INFO -- : (0.000062s) CREATE TABLE `users_groups` (`user_id` integer REFERENCES `users`, `group_id` integer REFERENCES `groups`) | |
I, [2015-11-11T18:21:57.979194 #52590] INFO -- : (0.000039s) INSERT INTO `users` (`id`, `name`) VALUES (1, 'Jane') | |
I, [2015-11-11T18:21:57.979321 #52590] INFO -- : (0.000027s) INSERT INTO `groups` (`id`, `name`) VALUES (1, 'Admins') | |
I, [2015-11-11T18:21:57.979398 #52590] INFO -- : (0.000025s) INSERT INTO `groups` (`id`, `name`) VALUES (2, 'Editors') | |
I, [2015-11-11T18:21:57.979486 #52590] INFO -- : (0.000025s) INSERT INTO `users_groups` (`user_id`, `group_id`) VALUES (1, 1) | |
I, [2015-11-11T18:21:57.979558 #52590] INFO -- : (0.000026s) IN |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ActionRender | |
include ActionView::Helpers | |
def button | |
link_to('User', '/users/1') | |
end | |
end | |
action_renderer = ActionRender.new | |
rodakase_renderer = Rodakase::View::Renderer.new(Pathname(__FILE__).dirname.join('templates'), engine: :erb) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# WHAT'S POSSIBLE ALREADY | |
class User | |
include Virtus.model | |
attribute :id | |
attribute :name | |
attribute :email | |
end | |
class UserMapper |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rom' | |
require 'rom-http' | |
require 'rom-repository' | |
require 'json' | |
require 'uri' | |
require 'net/http' | |
class RequestHandler | |
def call(dataset) | |
uri = URI(dataset.uri) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
irb(main):001:0> A = Module.new | |
=> A | |
irb(main):002:0> B = Module.new | |
=> B | |
irb(main):003:0> C = Class.new | |
=> C | |
irb(main):004:0> D = Class.new(C) { include A, B } | |
=> D | |
irb(main):005:0> D < C | |
=> true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'rom' | |
require 'rom-rails' | |
`rm -Rf /tmp/romtest.sqlite` | |
ROM.setup(:sql, 'sqlite:///tmp/romtest.sqlite') | |
class Events < ROM::Relation[:sql] | |
end | |
class Organisers < ROM::Relation[:sql] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'anima' | |
require 'transproc' | |
require 'virtus' | |
require 'benchmark/ips' | |
USERS = 1000.times.map { |i| { id: "#{i+1}", name: "User #{i+1}", age: "#{(i+1)*2}" } } | |
module Mappings |