Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
How to build gems for Rails
Search
naoty
January 31, 2013
Programming
200
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
450
Repository pattern in Swift
naoty
3
6.5k
Timepiece
naoty
0
3.9k
Contribution to Rails
naoty
0
4.5k
久々のRailsプロジェクトで導入した開発環境
naoty
2
1.2k
Report of DIYish programming activity
naoty
1
300
Qiita/Kobito vs ?
naoty
0
220
Other Decks in Programming
See All in Programming
ジョジョの世界をXRで再現する
mofurune
0
120
スマートフォンでモールス信号を送受信する 〜スマートフォンのLEDとカメラで作る光通信の設計と実装〜
atsuki_seo
0
230
setup-vp GitLab対応の裏側
naokihaba
0
150
GemmaをJevのように使ってみる / Use Gemma like Jev
kishida
5
680
Androidだけじゃない、DroidKaigiで広がった私の技術スタック
akkeylab
0
120
Security issues being discussed on Web Platforms
petamoriken
0
1.4k
Streamlitで実現する自然言語データアプリ開発
ayumu_yamaguchi
1
340
見えないものを探る要求要件定義に必要な基本的思考 / invisible-requirement-thinking
minodriven
14
6.6k
R8 の設定見直しでアプリサイズ削減
andpad
0
140
Simple Storage Service(S3) is not simple
iwatsukayura
0
190
速く作れる。その次は、速く確かめられる開発へ 〜AIネイティブ開発を支える、Shift Down〜 / Can build fast. Next, moving to development where we can verify fast.
rkaga
8
5.5k
プロダクトコードからライブラリの境界を見つける
elmetal
PRO
0
100
Featured
See All Featured
KATA
mclloyd
PRO
35
16k
Navigating the Design Leadership Dip - Product Design Week Design Leaders+ Conference 2024
apolaine
2
460
Build The Right Thing And Hit Your Dates
maggiecrowley
39
3.5k
Embracing the Ebb and Flow
colly
88
5.2k
Lessons Learnt from Crawling 1000+ Websites
charlesmeaden
PRO
1
1.6k
Google's AI Overviews - The New Search
badams
0
1.6k
Why You Should Never Use an ORM
jnunemaker
PRO
61
10k
Building a Scalable Design System with Sketch
lauravandoore
464
34k
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.4k
Marketing Yourself as an Engineer | Alaka | Gurzu
gurzu
0
320
StorybookのUI Testing Handbookを読んだ
zakiyama
31
7k
The Language of Interfaces
destraynor
162
27k
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༵