Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
Building an ORM with Arel
Search
Prathamesh Sonpatki
August 22, 2014
Technology
410
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
120
The Complete Handbook to OpenTelemetry Metrics
prathamesh
1
100
Breaking down the Pillars of Observability: From data to outcomes
prathamesh
0
120
Monitoring vs. Debugging
prathamesh
0
200
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
130
Other Decks in Technology
See All in Technology
『GOエコノミー 』(相乗りサービス) におけるスペック駆動開発
mot_techtalk
1
220
Snowflake Horizon Catalog と Apache Iceberg で作る オープンなデータ基盤
kitagawaz
0
390
AI 時代の Azure エンジニアリング ~ 私たちは何を磨き、何を任せるのか ~
chack411
1
370
Codex概要
ymiya55
0
240
The seven pitfalls of AI (revised version)
ufried
0
220
AWS FinOps Agent 結局何が得意なの?
siromi
0
230
メルカリにおけるAI時代の高速プロトタイピング基盤「Arca」
ryotarai
18
14k
Swap and Memory Reclaim - Squeezing Out More RAM
ennael
PRO
1
1.5k
生成AIと進める探索的データ分析(2026.10.03 第122回Tokyo.R勉強会)
tatamiya
2
1.3k
Claude起点の仕様駆動開発
tanakaseiya
0
300
「とりあえず動く」の先へ。 AI時代のチーム開発と内部設計/2026-slsdays
slsops
0
110
HacobuにおけるFDEとは/登壇資料(戸井田 裕貴)
hacobu
PRO
1
720
Featured
See All Featured
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
37
6.6k
Fireside Chat
paigeccino
43
4k
Context Engineering - Making Every Token Count
addyosmani
9
1.2k
A Tale of Four Properties
chriscoyier
163
24k
Docker and Python
trallard
47
4.2k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.6k
16th Malabo Montpellier Forum Presentation
akademiya2063
PRO
0
390
For a Future-Friendly Web
brad_frost
183
10k
What the history of the web can teach us about the future of AI
inesmontani
PRO
1
720
Evolution of real-time – Irina Nazarova, EuRuKo, 2024
irinanazarova
9
1.6k
Building AI with AI
inesmontani
PRO
1
1.3k
RailsConf 2023
tenderlove
30
1.6k
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