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
Building an ORM with Arel
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Prathamesh Sonpatki
August 28, 2014
Technology
71
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
Building an ORM with Arel
This talk was presented at RubyConf Brasil 2014 with @vipulnsward
Prathamesh Sonpatki
August 28, 2014
More Decks by Prathamesh Sonpatki
See All by Prathamesh Sonpatki
Secrets to Monitor Kubernetes Workloads
prathamesh
1
120
The Complete Handbook to OpenTelemetry Metrics
prathamesh
1
96
Breaking down the Pillars of Observability: From data to outcomes
prathamesh
0
110
Monitoring vs. Debugging
prathamesh
0
190
Handling High Cardinality in Observability
prathamesh
1
120
Setting up Monitoring for Kubernetes
prathamesh
0
320
Monitoring vs. Debugging - SRE BLR Meetup
prathamesh
0
110
Monitoring vs. Debugging - IG Meetup 22nd July
prathamesh
2
130
Pune_User_Group.pdf
prathamesh
0
120
Other Decks in Technology
See All in Technology
変化の早いClaude Codeを 書籍に落とし込む
oikon48
7
1.3k
モノリス Rails でも日中に rails db:migrate を走らせたい! / Daytime rails db:migrate on Monolithic Rails!
euglena1215
4
550
Service Connect 上のサービスに ECS Service の外側から到達できなかった話
ota1022
1
210
サイバー捜査員研修(後半)
nomizone
1
820
Digitization部 紹介資料
sansan33
PRO
2
7.7k
Webアクセシビリティ入門 2026
recruitengineers
PRO
3
480
社内の7割が使うデータ基盤を、 データチーム2人で回すためにやったこと
koh_yoshi
4
1.3k
ラジオの科学
frievea
0
290
[しろおび夏祭り2026] チャットするAIから、作業するAIへ - 使われ方の変化と、その裏側で起きていること
kk0n
0
1.7k
ガバメントクラウドでのランサムウェア対策
techniczna
2
1k
Goでデータパイプラインを作ろう
sansantech
PRO
1
360
TypeScript入門 2026
recruitengineers
PRO
3
520
Featured
See All Featured
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.6k
The Spectacular Lies of Maps
axbom
PRO
1
890
New Earth Scene 8
popppiees
3
2.5k
Tips & Tricks on How to Get Your First Job In Tech
honzajavorek
1
680
The Pragmatic Product Professional
lauravandoore
37
7.4k
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
160
[SF Ruby Conf 2025] Rails X
palkan
2
1.3k
The Illustrated Children's Guide to Kubernetes
chrisshort
51
53k
Technical Leadership for Architectural Decision Making
baasie
3
470
State of Search Keynote: SEO is Dead Long Live SEO
ryanjones
0
240
The browser strikes back
jonoalderson
0
1.5k
Hiding What from Whom? A Critical Review of the History of Programming languages for Music
tomoyanonymous
3
1.1k
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