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
290
Qiita/Kobito vs ?
naoty
0
210
Other Decks in Programming
See All in Programming
モックわからないマン卒業記 ~振る舞いを起点に見直した、フロントエンドテストにおけるモックの使いどころ~
tasukuwatanabe
2
270
ポーリング処理廃止によるイベント駆動アーキテクチャへの移行
seitarof
3
1.1k
2026年は Rust 置き換えが流行る! / 20260220-niigata-5min-tech
girigiribauer
0
230
DSPy入門 Pythonで実現する自動プロンプト最適化 〜人手によるプロンプト調整からの卒業〜
seaturt1e
1
710
「やめとこ」がなくなった — 1月にZennを始めて22本書いた AI共創開発のリアル
atani14
0
380
Codexに役割を持たせる 他のAIエージェントと組み合わせる実務Tips
o8n
4
1.3k
DevinとClaude Code、SREの現場で使い倒してみた件
karia
1
1k
nuget-server - あなたが必要だったNuGetサーバー
kekyo
PRO
0
240
Vuetify 3 → 4 何が変わった?差分と移行ポイント10分まとめ
koukimiura
0
130
Goの型安全性で実現する複数プロダクトの権限管理
ishikawa_pro
2
320
20260228_JAWS_Beginner_Kansai
takuyay0ne
5
510
Cyrius ーLinux非依存にコンテナをネイティブ実行する専用OSー
n4mlz
0
140
Featured
See All Featured
Become a Pro
speakerdeck
PRO
31
5.8k
So, you think you're a good person
axbom
PRO
2
2k
Improving Core Web Vitals using Speculation Rules API
sergeychernyshev
21
1.4k
Six Lessons from altMBA
skipperchong
29
4.2k
Context Engineering - Making Every Token Count
addyosmani
9
750
The Success of Rails: Ensuring Growth for the Next 100 Years
eileencodes
47
8k
Side Projects
sachag
455
43k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.8k
[SF Ruby Conf 2025] Rails X
palkan
2
830
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
12
1.1k
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
64
53k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
290
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༵