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
How to build gems for Rails
Search
naoty
January 31, 2013
Programming
1
180
How to build gems for Rails
naoty
January 31, 2013
Tweet
Share
More Decks by naoty
See All by naoty
Modular API Client
naoty
1
430
Repository pattern in Swift
naoty
3
6.4k
Timepiece
naoty
0
3.7k
Contribution to Rails
naoty
0
4.4k
久々のRailsプロジェクトで導入した開発環境
naoty
2
1.2k
Report of DIYish programming activity
naoty
1
280
Qiita/Kobito vs ?
naoty
0
200
Other Decks in Programming
See All in Programming
Navigation 3: 적응형 UI를 위한 앱 탐색
fornewid
1
510
re:Invent 2025 のイケてるサービスを紹介する
maroon1st
0
160
Giselleで作るAI QAアシスタント 〜 Pull Requestレビューに継続的QAを
codenote
0
330
ThorVG Viewer In VS Code
nors
0
530
AtCoder Conference 2025
shindannin
0
880
GoLab2025 Recap
kuro_kurorrr
0
790
LLMで複雑な検索条件アセットから脱却する!! 生成的検索インタフェースの設計論
po3rin
4
1.1k
生成AI時代を勝ち抜くエンジニア組織マネジメント
coconala_engineer
0
37k
2年のAppleウォレットパス開発の振り返り
muno92
PRO
0
180
これならできる!個人開発のすゝめ
tinykitten
PRO
0
140
QAフローを最適化し、品質水準を満たしながらリリースまでの期間を最短化する #RSGT2026
shibayu36
0
690
Developing static sites with Ruby
okuramasafumi
1
340
Featured
See All Featured
Six Lessons from altMBA
skipperchong
29
4.1k
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
0
110
Efficient Content Optimization with Google Search Console & Apps Script
katarinadahlin
PRO
0
270
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
31
3.1k
The Power of CSS Pseudo Elements
geoffreycrofte
80
6.1k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2k
CSS Pre-Processors: Stylus, Less & Sass
bermonpainter
359
30k
What’s in a name? Adding method to the madness
productmarketing
PRO
24
3.9k
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
0
390
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
35
2.3k
How to audit for AI Accessibility on your Front & Back End
davetheseo
0
130
KATA
mclloyd
PRO
33
15k
Transcript
How to build gems for Rails @naoty_k 131݄31༵
@naoty_k • Ruby on Rails (2010~) • Android (2012.5~) •
iOS (2012.10~) • vimmer!!! • curl http://cui-about.me/naoty 131݄31༵
Talk about... w1BSBNT*ORVJSFSʹ͍ͭͯ w3BJMTʹΈࠐΉ(FNʹඞཁͳͷ wιʔείʔυΛಡΜͰ্͍͘Ͱඞཁͳ 5JQT 131݄31༵
ParamsInquirer $ gem install params_inquirer $ irb 001 > require
‘params_inquirer’ 002 > params = ParamsInquirer::Parameters.new 003 > params[:name] = ‘naoty’ 004 > params[:name].naoty? => true 005 > params[:name].someone? => false 131݄31༵
ParamsInquirer on Rails def index if params[:status].accepted? # ... elsif
params[:status].rejected? # ... end end 131݄31༵
Railtie class Railtie < ::Rails::Railtie initializer ‘Initialize your gem’ do
ActiveSupport.on_load(:action_controller) do ::ActionController::Base.send :include, ParamsInquirer::ActionController::Base end end end 131݄31༵
action_controller/base.rb module ActionController class Base < Metal # ... ActiveSupport.run_load_hooks(:action_controller,
self) end end 131݄31༵
lib/params_inquirer.rb if defined?(Rails) require ‘params_inquirer/railtie’ else require ‘params_inquirer/parameters’ end 131݄31༵
ActiveSupport::Concern module M def self.included(self) base.extend ClassMethods scope :disabled, where(disabled:
true) end module ClassMethods # ... end end 131݄31༵
ActiveSupport::Concern module M extend ActiveSupport::Concern included do scope :disabled, where(disabled:
true) end module ClassMethods # ... end end 131݄31༵
ActiveSupport::Autoload autoload(:Hoge, ‘hoge’) # ‘hoge.rb‘͜ͷ࣌Ͱrequire͞Ε͍ͯͳ͍ p Hoge # ͜͜Ͱ‘hoge.rb’͕require͞ΕΔ extend
ActiceSupport::Autoload autoload :Fuga p Fuga # ͜͜Ͱ‘fuga.rb’͕require͞ΕΔ 131݄31༵