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
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Prathamesh Sonpatki
August 22, 2014
Technology
390
0
Share
Building an ORM with Arel
Talk given at Madison Ruby 2014 with @vipulnsward
Prathamesh Sonpatki
August 22, 2014
More Decks by Prathamesh Sonpatki
See All by Prathamesh Sonpatki
Secrets to Monitor Kubernetes Workloads
prathamesh
1
110
The Complete Handbook to OpenTelemetry Metrics
prathamesh
1
76
Breaking down the Pillars of Observability: From data to outcomes
prathamesh
0
98
Monitoring vs. Debugging
prathamesh
0
170
Handling High Cardinality in Observability
prathamesh
1
110
Setting up Monitoring for Kubernetes
prathamesh
0
300
Monitoring vs. Debugging - SRE BLR Meetup
prathamesh
0
92
Monitoring vs. Debugging - IG Meetup 22nd July
prathamesh
2
120
Pune_User_Group.pdf
prathamesh
0
110
Other Decks in Technology
See All in Technology
生成AIが変える SaaS の競争原理と弁護士ドットコムのプロダクト戦略
bengo4com
1
2.6k
バイブコーディングで3倍早く⚪⚪を作ってみた
samakada
0
190
AI時代における技術的負債への取り組み
codenote
1
1.9k
AIが盛んな時代に 技術記事を書き始めて起きた私の中での小さな変化
peintangos
0
280
Route 53 Global Resolver で高額課金発生!
otanikohei2023
0
130
PyCon JPに学ぶ『決め方の決め方』: TechLead Conference 2026
terapyon
1
200
Agents CLI と Gemini Enterprise Agent Platform で マルチエージェント開発が楽しくなる!
kaz1437
0
180
音声言語モデル手法に関する発表の紹介
kzinmr
0
150
ハーネスエンジニアリングをやりすぎた話 ~そのハーネスは解体された~
gotalab555
5
1.9k
Expiration of Secure Boot Certificates for vSphere Virtual Machines
mirie_sd
0
120
Do Ruby::Box dream of Modular Monolith?
joker1007
1
360
「誰一人取り残されない」 AIエージェント時代のプロダクト設計思想 Product Management Summit 2026
mizushimac
1
1.9k
Featured
See All Featured
The Invisible Side of Design
smashingmag
303
52k
Test your architecture with Archunit
thirion
1
2.2k
Site-Speed That Sticks
csswizardry
13
1.2k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
49
9.9k
A Tale of Four Properties
chriscoyier
163
24k
AI in Enterprises - Java and Open Source to the Rescue
ivargrimstad
0
1.2k
職位にかかわらず全員がリーダーシップを発揮するチーム作り / Building a team where everyone can demonstrate leadership regardless of position
madoxten
62
53k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.8k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
55k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
450
WCS-LA-2024
lcolladotor
0
550
sira's awesome portfolio website redesign presentation
elsirapls
0
220
Transcript
Building an ORM with ARel Walking up the AS(Tree) @vipulnsward,
@_cha1tanya
Vipul @vipulnsward && Prathamesh @_cha1tanya
None
26 Hours
48 Hours
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
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
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 •
...
Thank You! gh: prathamesh-sonpatki/torm @vipulnsward @_cha1tanya