Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
rom 4.0 is coming
Search
Piotr Solnica
July 09, 2017
Programming
920
3
Share
rom 4.0 is coming
Piotr Solnica
July 09, 2017
More Decks by Piotr Solnica
See All by Piotr Solnica
[KRUG] Architecture. The reclaimed years.
solnic
2
530
rom-rb 4.0 - Moscow, RailsClub 2017
solnic
3
1.3k
Blending Functional and OO programming in Ruby
solnic
22
2.5k
Deep Dive Into ROM
solnic
7
1.3k
Clean Code Cowboy
solnic
4
1.1k
Convenience vs Simplicity
solnic
4
1.9k
Micro Libraries FTW
solnic
2
650
DataMapper 2 - an object mapping toolkit
solnic
6
1.1k
Beyond the ORM - RuLu Conf 2012
solnic
1
1.5k
Other Decks in Programming
See All in Programming
SkillがSkillを生む:QA観点出しを自動化した
sontixyou
6
3.4k
Coding as Prompting Since 2025
ragingwind
0
840
年間50登壇、単著出版、雑誌寄稿、Podcast出演、YouTube、CM、カンファレンス主催……全部やってみたので面白さ等を比較してみよう / I’ve tried them all, so let’s compare how interesting they are.
nrslib
4
790
PHPで TLSのプロトコルを実装してみるをもう一度しゃべりたい
higaki_program
0
210
PDI: Como Alavancar Sua Carreira e Seu Negócio
marcelgsantos
0
120
AWS re:Invent 2025の少し振り返り + DevOps AgentとBacklogを連携させてみた
satoshi256kbyte
3
170
「話せることがない」を乗り越える 〜日常業務から登壇テーマをつくる思考法〜
shoheimitani
4
830
AI時代のPhpStorm最新事情 #phpcon_odawara
yusuke
0
190
アーキテクチャモダナイゼーションとは何か
nwiizo
19
5.3k
Don't Prompt Harder, Structure Better
kitasuke
0
770
第3木曜LT会 #28
tinykitten
PRO
0
110
おれのAgentic Coding 2026/03
tsukasagr
1
150
Featured
See All Featured
A Tale of Four Properties
chriscoyier
163
24k
Designing for Timeless Needs
cassininazir
0
200
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.2k
Leadership Guide Workshop - DevTernity 2021
reverentgeek
1
270
AI Search: Where Are We & What Can We Do About It?
aleyda
0
7.3k
Save Time (by Creating Custom Rails Generators)
garrettdimon
PRO
32
2.8k
Information Architects: The Missing Link in Design Systems
soysaucechin
0
890
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.4k
Music & Morning Musume
bryan
47
7.2k
Beyond borders and beyond the search box: How to win the global "messy middle" with AI-driven SEO
davidcarrasco
3
110
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.4k
Transcript
ROM-RB 4.0 IS COMING PIOTR SOLNICA >> BRIGHTON RUBY 2017
1
PIOTR SOLNICA > ! Cracow, Poland > github.com/solnic > @_solnic_
> solnic.eu 2
TECH LEAD AT ICELAB 3
WHAT'S ROM-RB? 4
an open-source persistence and mapping toolkit for Ruby built for
speed and simplicity 5
DATABASE-AGNOSTIC, FLEXIBLE, EXTENDIBLE, FAST, SIMPLE 6
FOR REAL ! 7
SOUNDS LIKE SOME CRAZY OBJECT RELATIONAL MAPPER, EH? 8
ROM IS NOT AN ORM 9
WHY DOES IT EVEN EXIST? 10
A TRUE ALTERNATIVE TO ACTIVE RECORD 11
ROM-RB PROVIDES A WAY TO SEPARATE PERSISTENCE CONCERNS FROM APPLICATION
DOMAIN 12
WHAT'S THE DEAL WITH 4.0? 13
RUBYISTS LOVE MAGIC ˾(✿˙ᗜ˙)੭ʓ̤ꚍ.*ꙓꙏꚍ 14
MAGIC AKA: IMPLICIT CODE AKA: EASY TO USE ABSTRACTIONS 15
ACTIVERECORD POSSIBLY THE MOST MAGICAL GEM IN THE UNIVERSE 16
NO BOILERPLATE class User < ActiveRecord::Base end 17
PERSISTENCE, SO SIMPLE user = User.create(name: "Jane") 18
QUERIES, SO SIMPLE User.where(name: "Jane").first 19
MAKING CHANGES, SO SIMPLE User.where(name: "Jane").update_all(name: "Jane Doe") 20
EASE OF USE > Little code to write to get
started > A lot of functionality OOTB > No boilerplate 21
THIS IS A REAL CHALLENGE FOR ROM-RB! 22
> Dynamic query interface > Explicit representation of data structures
> Mapping to struct objects decoupled from the database > No concept of lazy-loadable associations 23
THIS IS FINE 24
WE MADE IT (⊃ꙏ•́‿•̀ꙏ)⊃━☆ꚍ.*ꙓꙏꚍ 25
RELATIONS AND STRUCTS 26
class Users < ROM::Relation[:sql] schema(infer: true) end 27
✅ NO BOILERPLATE 28
users.changeset(:create, name: "Jane").commit # => #<ROM::Struct::User id=1 name="Jane"> 29
✅ PERSISTENCE, SO SIMPLE 30
users.where(name: "Jane").first # => #<ROM::Struct::User id=1 name="Jane"> 31
✅ QUERIES, SO SIMPLE 32
users.where(name: "Jane").changeset(:update, name: "Jane Doe").commit # => #<ROM::Struct::User id=1 name="Jane
Doe"> 33
✅ MAKING CHANGES, SO SIMPLE 34
BUT... 35
users.first # => #<ROM::Struct::User id=1 name="Jane"> users.select(:name).first # => #<ROM::Struct::User
name="Jane"> 36
PEOPLE WANT THEIR OWN METHODS, OBVIOUSLY 37
class User < ActiveRecord::Base def first_name name.split(' ').first end def
last_name name.split(' ').last end end 38
ROM-RB: CUSTOM STRUCT NAMESPACE 39
class Users < ROM::Relation[:sql] struct_namespace Entities schema(infer: true) end 40
class Users < ROM::Relation[:sql] struct_namespace Entities schema(infer: true) end 41
module Entities class User < ROM::Struct def first_name name.split(' ').first
end def last_name name.split(' ').last end end end 42
module Entities class User < ROM::Struct def first_name name.split(' ').first
end def last_name name.split(' ').last end end end 43
user = users.first => #<Entities::User id=1 name="Jane Doe"> user.first_name #
"Jane" user.last_name # "Doe" 44
user = users.select(:name).first => #<Entities::User name="Jane Doe"> user.first_name # "Jane"
user.last_name # "Doe" 45
WHAT DOES THIS MEAN, REALLY? ! 46
THE TRUTH ABOUT MAGIC 47
EXCITEMENT ABOUT MAGIC (AKA HAPPINESS) 48
ROM-RB DOESN'T ENFORCE MAGIC! 49
AT ANY POINT IN TIME YOU CAN DEFINE STRUCTS WITH
EXPLICIT ATTRIBUTES AND ASK ROM-RB TO LOAD THEM 50
require "entities/address" module Entities class UserProfile < ROM::Struct attribute :email,
Types::Strict::String attribute :name, Types::Strict::String attribute :age, Types::Strict::Integer attribute :address, Address end end 51
users.combine(:address).as(:user_profile).first 52
HOWEVER...THIS REQUIRES TIME, AND GOOD UNDERSTANDING OF THE APPLICATION DOMAIN!
53
IT'S A PROCESS, AND ROM-RB FULLY SUPPORTS IT 54
4.0.0.BETA WAS RELEASED A COUPLE WEEKS AGO ! (JUST SAYING!)
55
THANK YOU ! ! GITHUB.COM/ROM-RB/ROM 56