Lock in $30 Savings on PRO—Offer Ends Soon! ⏳
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Building an ORM with Arel
Search
Prathamesh Sonpatki
August 28, 2014
Technology
0
53
Building an ORM with Arel
This talk was presented at RubyConf Brasil 2014 with @vipulnsward
Prathamesh Sonpatki
August 28, 2014
Tweet
Share
More Decks by Prathamesh Sonpatki
See All by Prathamesh Sonpatki
Secrets to Monitor Kubernetes Workloads
prathamesh
1
96
The Complete Handbook to OpenTelemetry Metrics
prathamesh
1
66
Breaking down the Pillars of Observability: From data to outcomes
prathamesh
0
70
Monitoring vs. Debugging
prathamesh
0
140
Handling High Cardinality in Observability
prathamesh
1
98
Setting up Monitoring for Kubernetes
prathamesh
0
290
Monitoring vs. Debugging - SRE BLR Meetup
prathamesh
0
84
Monitoring vs. Debugging - IG Meetup 22nd July
prathamesh
2
110
Pune_User_Group.pdf
prathamesh
0
110
Other Decks in Technology
See All in Technology
pmconf2025 - データを活用し「価値」へ繋げる
glorypulse
0
560
Ryzen NPUにおけるAI Engineプログラミング
anjn
0
240
プロダクトマネジメントの分業が生む「デリバリーの渋滞」を解消するTPMの越境
recruitengineers
PRO
3
540
小さな判断で育つ、大きな意思決定力 / 20251204 Takahiro Kinjo
shift_evolve
PRO
1
410
Security Diaries of an Open Source IAM
ahus1
0
120
MS Ignite 2025で発表されたFoundry IQをRecap
satodayo
3
240
Introduction to Sansan for Engineers / エンジニア向け会社紹介
sansan33
PRO
5
49k
こがヘンだよ!Snowflake?サービス名称へのこだわり
tarotaro0129
0
110
Claude Code はじめてガイド -1時間で学べるAI駆動開発の基本と実践-
oikon48
44
27k
最近のLinux普段づかいWaylandデスクトップ元年
penguin2716
1
370
直接メモリアクセス
koba789
0
180
世界最速級 memcached 互換サーバー作った
yasukata
0
200
Featured
See All Featured
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
120
20k
Java REST API Framework Comparison - PWX 2021
mraible
34
9k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
PRO
196
69k
The Invisible Side of Design
smashingmag
302
51k
The Hidden Cost of Media on the Web [PixelPalooza 2025]
tammyeverts
1
86
Imperfection Machines: The Place of Print at Facebook
scottboms
269
13k
[SF Ruby Conf 2025] Rails X
palkan
0
460
How to Ace a Technical Interview
jacobian
280
24k
Rebuilding a faster, lazier Slack
samanthasiow
84
9.3k
How GitHub (no longer) Works
holman
316
140k
Into the Great Unknown - MozCon
thekraken
40
2.2k
Making Projects Easy
brettharned
120
6.5k
Transcript
Olá
Building an ORM with ARel Walking up the AS(Tree) @vipulnsward,
@_cha1tanya
Vipul @vipulnsward && Prathamesh @_cha1tanya
None
None
None
RubyIndia.org
None
podcast.rubyindia.org
Indian Ruby Conferences RubyConfIndia Garden City Ruby Conf DeccanRubyConf Do
visit India!
Building an ORM with ARel Walking up the (AS)Tree @vipulnsward,
@_cha1tanya
None
None
Build our own ORM - Why?
Object-relational mapping (ORM, O/RM, and O/R mapping) in computer science
is a programming technique for converting data between incompatible type systems in object- oriented programming languages. This creates, in effect, a "virtual object database" that can be used from within the programming language.
Active Record “An object that wraps a row in a
database table or view, encapsulates the database access, and adds domain logic on that data.”
Components • Database connection • Query Generator • Attribute Access
• Typecasting
SQL torm_development=# select * from posts; id | name |
content | author | subject -----+-------------+---------+------------+--------- 332 | RGenGC| Restricted Generation Garbage Collection | GorbyPuff | How does RGenGC work? (1 row)
Object Post: id: 332, name: ‘RGenGC’, subject: ‘How does RGenGC
work?’ content: ‘Restricted Generation Garbage Collection’ author: ‘GorbyPuff’
Object Post: id(int): 332, name(string): ‘RGenGC’, subject(string): ‘How does RGenGC
work?’ content(string): ‘Restricted Generation Garbage Collection’ author(string): ‘GorbyPuff’
What? post = Post.new subject: 'What is RGenCG?' post.save first_post
= Post.find(1) puts first_post.subject #=> 'What is RGenCG?'
How? class Post < Torm::Model … end
Role of ARel
ARel • Relational Algebra for Ruby • ARel is a
SQL AST manager for Ruby • Can generate complex SQL queries • Adapts to multiple databases
ARel Components • AST • Visitors • Managers
ORM Database ARel
Engine • Provide information to ARel/ Attributes Access • Column
/ Table structure • Database Adapter • Data Type Mappings
Engine Skeleton
Database Connection
Columns
Schema Cache
None
Tests
None
Attributes • Data Types • Casting from / to database
types • Attribute Maps for table • Accessors for a model
Types • Types • TypeMap • Attribute • AttributeSet
Attribute Accessors • Readers • Writes • Initializer
Database Statements • create • update • save • destroy
Querying • find • count • where • delete_all •
...
Summary • Database Connection • Creating columns/ Schema cache •
Attribute Types/ Type casting • Attributes and accessors • Database statements • Querying
Other • Associations • Migrations • Callbacks • Validations •
...
Obrigado! gh: prathamesh-sonpatki/torm @vipulnsward @_cha1tanya