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
190
1
Share
How to build gems for Rails
naoty
January 31, 2013
More Decks by naoty
See All by naoty
Modular API Client
naoty
1
440
Repository pattern in Swift
naoty
3
6.5k
Timepiece
naoty
0
3.8k
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
NakouPAY説明用
annouim0
0
150
AWSコミュニティ活動は顧客のクラウド推進に効くのか / Do AWS community activities help customers adopt the cloud?
seike460
PRO
0
140
ハーネスエンジニアリングとは?
kinopeee
10
5.3k
JOAI2026 1st solution - heron0519 -
heron0519
0
140
AI時代のPhpStorm最新事情 #phpcon_odawara
yusuke
0
190
Angular Signal Forms
debug_mode
0
110
実践CRDT
tamadeveloper
0
570
Lightning-Fast Method Calls with Ruby 4.1 ZJIT / RubyKaigi 2026
k0kubun
3
410
의존성 주입과 모듈화
fornewid
0
140
「Linuxサーバー構築標準教科書」を読んでみた #ツナギメオフライン.7
akase244
0
1.4k
AIエージェントで業務改善してみた
taku271
0
530
ローカルで稼働するAI エージェントを超えて / beyond-local-ai-agents
gawa
3
280
Featured
See All Featured
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
200
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.2k
Redefining SEO in the New Era of Traffic Generation
szymonslowik
1
280
More Than Pixels: Becoming A User Experience Designer
marktimemedia
3
380
[SF Ruby Conf 2025] Rails X
palkan
2
960
The AI Revolution Will Not Be Monopolized: How open-source beats economies of scale, even for LLMs
inesmontani
PRO
3
3.4k
Jamie Indigo - Trashchat’s Guide to Black Boxes: Technical SEO Tactics for LLMs
techseoconnect
PRO
0
110
30 Presentation Tips
portentint
PRO
1
270
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
1
350
So, you think you're a good person
axbom
PRO
2
2k
DBのスキルで生き残る技術 - AI時代におけるテーブル設計の勘所
soudai
PRO
64
53k
My Coaching Mixtape
mlcsv
0
100
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༵