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
Sponsored
·
Ship Features Fearlessly
Turn features on and off without deploys. Used by thousands of Ruby developers.
→
naoty
January 31, 2013
Programming
190
1
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
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
300
Qiita/Kobito vs ?
naoty
0
210
Other Decks in Programming
See All in Programming
ルールを書いて終わらせないハーネスエンジニアリング
yug1224
3
1.5k
Foundation Models frameworkで画像分析
ryodeveloper
1
120
Generative UI & AI-Assistants for Your Angular Solutions
manfredsteyer
PRO
0
110
Laravelで学ぶ Webアプリケーションチューニング入門/web_application_tuning_101
hanhan1978
4
770
symfony/aiとlaravel/boost
77web
0
130
継続モナドとリアクティブプログラミング
yukikurage
3
610
フィードバックで育てるAI開発
kotaminato
1
120
ランチタイムLT会3周年!ランチタイムLT会を3年間続けられたお話
y0hgi
1
140
SLOをサービス品質の共通言語にするために 取り組んできたこと
wakana0222
0
510
Performance Engineering for Everyone
elenatanasoiu
0
270
ローカルLLMでどこまでコードが書けるか -縮小版 / How much code can be written on a local LLM Shortened
kishida
2
190
壊れたパーサから始める関数型設計と構成的なパーサ #fp_matsuri
raiga0310
2
250
Featured
See All Featured
Google's AI Overviews - The New Search
badams
0
1.1k
Building Applications with DynamoDB
mza
96
7.1k
Rebuilding a faster, lazier Slack
samanthasiow
85
9.6k
svc-hook: hooking system calls on ARM64 by binary rewriting
retrage
2
340
SEO for Brand Visibility & Recognition
aleyda
0
4.6k
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.3k
The Curious Case for Waylosing
cassininazir
1
430
The #1 spot is gone: here's how to win anyway
tamaranovitovic
3
1.1k
Odyssey Design
rkendrick25
PRO
2
730
Claude Code どこまでも/ Claude Code Everywhere
nwiizo
65
56k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
34
2.8k
Thoughts on Productivity
jonyablonski
76
5.2k
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༵