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.4k
RailsでViewModel導入に 挫折しかけてる話@表参道.rb #44
yaboojp
1
820
サービス開発する平成の君に 昭和の僕から伝えたい7つのこと@平成.rb #2
yaboojp
0
750
RailsのCacheつかってますか?@表参道.rb #44
yaboojp
0
710
夏休みの宿題 8/31にやらない話 @Otemachi.rb #14
yaboojp
0
310
大掃除 on Rails @Otemachi.rb #12
yaboojp
1
33
使わない機能の倒し方 @s-dev talks 〜サービス開発勉強会〜 大忘年LT大会
yaboojp
0
88
Featured
See All Featured
Why You Should Never Use an ORM
jnunemaker
PRO
54
9.1k
The World Runs on Bad Software
bkeepers
PRO
65
11k
Navigating Team Friction
lara
183
15k
jQuery: Nuts, Bolts and Bling
dougneiner
61
7.5k
The Art of Delivering Value - GDevCon NA Keynote
reverentgeek
8
1.2k
KATA
mclloyd
29
14k
JavaScript: Past, Present, and Future - NDC Porto 2020
reverentgeek
47
5.1k
Writing Fast Ruby
sferik
628
61k
BBQ
matthewcrist
85
9.4k
Docker and Python
trallard
41
3.1k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
48
2.2k
Thoughts on Productivity
jonyablonski
67
4.3k
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