This file contains hidden or 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' | |
| ROM.setup(:memory) | |
| class Users < ROM::Relation[:memory] | |
| end | |
| class Tasks < ROM::Relation[:memory] | |
| end |
This file contains hidden or 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_DATA = {} | |
| BUNDLED_GEMS = `bundle show | grep "*" | awk '{print $2}'`.split("\n").sort | |
| require 'bigdecimal' | |
| def require(name) | |
| start = Time.now | |
| ret = super | |
| stop = Time.now | |
| total = BigDecimal(stop-start, 6) | |
| REQUIRE_DATA[name] = total if BUNDLED_GEMS.include?(name) |
This file contains hidden or 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
| module Virtus | |
| class PGArray < Attribute | |
| primitive Sequel::Postgres::PGArray | |
| def primitive | |
| options[:primitive] | |
| end | |
| def coerce(value) | |
| Sequel.pg_array(value) |
This file contains hidden or 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-sql' | |
| require 'virtus' | |
| module ActiveRecord | |
| class Base | |
| def self.inherited(klass) | |
| rel_class = Class.new(ROM::Relation[:sql]) { | |
| base_name Inflecto.tableize(klass.name).to_sym | |
| } | |
| dataset = repository.dataset(rel_class.base_name) |
This file contains hidden or 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-sql' | |
| setup = ROM.setup('postgres://localhost/rom') | |
| setup.default.adapter.connection.drop_table?(:users) | |
| setup.default.adapter.connection.drop_table?(:groups) | |
| setup.default.adapter.connection.create_table :groups do | |
| Integer :id | |
| String :name, null: false |
This file contains hidden or 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
| gem "rom", github: 'rom-rb/rom', branch: 'master' | |
| gem "rom-sql", github: 'rom-rb/rom-sql', branch: 'master' | |
| gem "rom-rails", github: 'rom-rb/rom-rails', branch: 'master' | |
| gem_group(:test) do | |
| gem "rspec" | |
| gem "rspec-rails" | |
| gem "capybara" | |
| gem "spring-commands-rspec" | |
| end |
This file contains hidden or 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 ------------------------------------- | |
| [ROM] Loading 1k user objects | |
| 29 i/100ms | |
| [AR] Loading 1k user objects | |
| 9 i/100ms | |
| ------------------------------------------------- | |
| [ROM] Loading 1k user objects | |
| 277.2 (±6.5%) i/s - 1392 in 5.040249s | |
| [AR] Loading 1k user objects | |
| 111.0 (±9.0%) i/s - 558 in 5.071423s |
This file contains hidden or 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
| -- create_table(:users) | |
| -> 0.0039s | |
| LOADED 1000 users via ROM/Sequel | |
| LOADED 1000 users via ActiveRecord | |
| Calculating ------------------------------------- | |
| rom.read(:user_json).all.to_a | |
| 16 i/100ms | |
| ARUser.all.map(&:as_json) | |
| 3 i/100ms | |
| ------------------------------------------------- |
This file contains hidden or 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 ArrayAdapter < ROM::Adapter | |
| def self.schemes | |
| [:array] | |
| end | |
| def initialize(uri) | |
| super | |
| @connection = {} | |
| end |
This file contains hidden or 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 'virtus' | |
| class Money | |
| include Virtus.value_object | |
| values do | |
| attribute :amount, Integer | |
| attribute :currency, String | |
| end | |
| end |