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
ぼくが考える最強のApplicationModel @表参道.rb #43
Search
YABOO JAPAN
February 07, 2019
0
660
ぼくが考える最強のApplicationModel @表参道.rb #43
YABOO JAPAN
February 07, 2019
Tweet
Share
More Decks by YABOO JAPAN
See All by YABOO JAPAN
RubyKaigiでもらった熱量がOSSに変換された話@AFTER RubyKaigi 2019
yaboojp
0
2.5k
RailsでViewModel導入に 挫折しかけてる話@表参道.rb #44
yaboojp
1
860
サービス開発する平成の君に 昭和の僕から伝えたい7つのこと@平成.rb #2
yaboojp
0
770
RailsのCacheつかってますか?@表参道.rb #44
yaboojp
0
730
夏休みの宿題 8/31にやらない話 @Otemachi.rb #14
yaboojp
0
320
大掃除 on Rails @Otemachi.rb #12
yaboojp
1
47
使わない機能の倒し方 @s-dev talks 〜サービス開発勉強会〜 大忘年LT大会
yaboojp
0
94
Featured
See All Featured
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
4
450
Stop Working from a Prison Cell
hatefulcrawdad
268
20k
Large-scale JavaScript Application Architecture
addyosmani
511
110k
Building an army of robots
kneath
303
45k
What's in a price? How to price your products and services
michaelherold
244
12k
Making the Leap to Tech Lead
cromwellryan
133
9.1k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
30
4.6k
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
330
21k
4 Signs Your Business is Dying
shpigford
183
22k
[RailsConf 2023 Opening Keynote] The Magic of Rails
eileencodes
28
9.3k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
160
15k
Testing 201, or: Great Expectations
jmmastey
42
7.2k
Transcript
΅͕͘ߟ͑Δ࠷ڧͷ ApplicationModel @yaboojp on Omotesando.rb #43 2019/2/6
Self • Name: େ༅ Ӭ / @yaboojp • Jobs: •
22Inc. Co-Founder & CTO @தࠇ • ex NTTdata @ஙʙ๛ऱ • Location: ژ -> ౦ژ • Favorites: Ϗʔϧ, Իָ, όΠΫ, JALϚΠϧ
None
ActiveRecord͡Όͳ͍ ModelઃܭͲ͏ͯ͠·͔͢ʁ
ฐࣾ • جຊతʹɺActiveModelύλʔϯ • PORO(Plain Old Ruby Object)ͰStructΛར༻ ͢Δͷྑͦ͞͏ͱࢥ͍ͭͭ •
ActiveModel::Attributes͕Rails5.2͔Β͑Δ ͷͰͬͺΓActiveModel͕ྑͦ͞͏
ActiveModel::Attributes
ॳ LT͠Α͏ͱͯͨ͠ωλ • not Rails 5.2
ActiveModel::DirtyͰมߋݕ
ɹʊਓਓਓਓਓਓਓਓਓਓਓʊ ʼɹɹɹɹɹɹɹɹɹɹɹɹʻ ʼɹ ͢ωλ͕ͳ͘ͳͬͨ ɹʻ ʼɹɹɹɹɹɹɹɹɹɹɹɹʻ ɹʉY^Y^Y^Y^Y^Y^Y^Y^Y^Y^Y^ʉ
ॳ LT͠Α͏ͱͯͨ͠ωλ • Rails 5.2Ҏ߱ͰෆཁͳϋοΫ
݁
Thanks
Thanks
None
None
Ͳ͏ͯ͜͠͏ͳͬͨʁ
ແବ ແବ ແବ ແବ
ActiveModelͷؾ࣋ͪʹͳΔ
None
૯ͨΓͷମͨΓ
Model
Attributes
Dirty
Serializers::JSON • API࣮ͰΑ͘ΘΕͯΔ • ::XMLͱ͔ଞͷϑΥʔϚοτͳ͔ͬͨ • ActiveModel::SerializationΛؚΉ
Validations • ActiveModel::Modelʹؚ·ΕΔ
Validator • ActiveModel::Modelʹؚ·ΕΔ
Attribute_methods • ActiveModel::Attributesʹinclude͞ΕͯΔ • prefix/suffix͖ͷڞ௨ϝιουΛ֤attribute ʹఆٛͰ͖Δ • ෦࣮ɺmethod_missingࠇຐज़
Attribute_mutation_tracker • ActiveModel::DirtyͰΘΕ͍ͯΔΤϯςΟ ςΟΫϥε
Attribute_set • ActiveModel::AttributesͰΘΕ͍ͯΔΤϯ ςΟςΟΫϥε
Callbacks • ActiveModel::Validationsʹinclude͞ΕͯΔ • ͳͷͰɺinclude ActiveModel::ModelͰOK
Attribute_assignment • ActiveModel::Modelʹؚ·ΕΔ • assign_attributesϝιουΛఏڙ
Attribute • Attribute_setͰར༻͞Ε͍ͯΔΫϥε
Secure_password
Conversion • ActiveModel::Modelʹؚ·ΕΔ • ୯ମͰར༻͢Δ͜ͱͳͦ͞͏?
Naming • ActiveModel::Modelʹؚ·ΕΔ • ୯ମͰར༻͢Δ͜ͱͳͦ͞͏?
Serialization • ActiveModel::Serializers::JSONʹؚ·ΕΔ • serializable_hashϝιου͕ར༻ՄʹͳΔ • ୯ମͰΘͳ͍? ͏?
ActiveModel::Translation • ActiveModel::Modelʹؚ·ΕΔ • human_attribute_nameϝιουΛఏڙ
Forbidden_attributes_protection • ͝ΊΜͳ͍͞ ϝϞɿ ࢿྉ࡞͕ؒʹ߹Θͳ͔ͬͨͷͰɺௌऺʹ͍͔͚ͯΓΔɻ μϝͩͬͨΒ॓ͱͯ࣋ͬͯ͠ؼͬͯΒ͏ʢΈͳ͞Μʹʣ
ActiveModel::Lint • ͝ΊΜͳ͍͞
ActiveModel::Railtie • ͝ΊΜͳ͍͞
ActiveModel::Type • ͝ΊΜͳ͍͞
͜ΜͲͦ݁͜
None
We Are Hiring
ActiveModel::Thanks