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 'dry-validation' | |
class EnvValidation | |
class ENV | |
def inspect | |
ivs = instance_variables.each { |v| "#{v}=#{instance_variable_get(v)}" }.join(', ') | |
"ENV[#{ivs}]" | |
end | |
def to_s |
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
Sequel.migration do | |
up do | |
create_table(:users) do | |
primary_key :id | |
String :first_name, null: false, limit: 100 | |
String :last_name, null: false, limit: 100 | |
String :middle_name, null: true, limit: 100 | |
String :email, null: false, limit: 500 | |
String :role, null: true, limit: 50 |
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
#!/usr/bin/env ruby | |
require "rom-sql" | |
require "rom-repository" | |
require "byebug" | |
module Persistence | |
module Relations | |
class Configurations < ROM::Relation[:sql] | |
gateway :bonuses |
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
#!/usr/bin/env ruby | |
require "bundler/setup" | |
require "rom-repository" | |
config = ROM::Configuration.new(:sql, 'postgres://localhost/rom_repository') | |
config.relation(:books) do | |
schema(:books) do | |
attribute :id, ROM::SQL::Types::Serial |
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
#!/usr/bin/env ruby | |
require "bundler/setup" | |
require "rom-repository" | |
config = ROM::Configuration.new(:sql, 'postgres://localhost/rom_repository') | |
config.relation(:books) do | |
schema(:books) do | |
attribute :id, ROM::SQL::Types::Serial |
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 'rom-repository' | |
rom = ROM.container(:sql, 'sqlite::memory') do |c| | |
c.gateways[:default].create_table :events do | |
primary_key :id | |
column :event_no, Integer | |
end | |
c.gateways[:default].create_table :orders do |
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' | |
require 'rom-sql' | |
DB = Sequel.connect('postgres://localhost/rom_sql') | |
DB.execute('create extension if not exists hstore ') | |
DB.drop_table?(:strings) | |
DB.create_table(:strings) do | |
primary_key(:id) | |
hstore :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
users: | |
- name: 'Jane' | |
email: '[email protected]' | |
- name: 'John' | |
email: '[email protected]' |
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 Jobs < ROM::Relation[:sql] | |
schema(:jobs) do | |
# ... | |
associations do | |
belongs_to :team | |
belongs_to :template | |
belongs_to :address | |
belongs_to :client | |
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 'rom' | |
require 'rom-repository' | |
require 'sqlite3' | |
rom = ROM.container(:sql, 'sqlite::memory') do |conf| | |
conf.default.create_table(:bookings) do | |
primary_key :booking_id | |
end | |
conf.default.create_table(:tickets) do |