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
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
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
言葉の格闘技のススメ~紙とペンと言葉から始める、キャリアの描き方~
progresscicada
2
140
<title><a id="</title>君はこのHTMLをパースできるか"></a></title> #雑LT_study
pizzacat83
0
140
属人化した知識を、 AIが辿れる地図にする
pkshadeck
PRO
1
150
Lean は証明の正しさを確認するためだけのツールって思ってませんか?
inoueasei
1
150
わからない話を追いかけたら、プログラミング言語を作る側にいた
ydah
3
480
【やさしく解説 設計編・中級 #1】一つの車に、運転手は一人 ~ある倉庫システムの事例から~
panda728
PRO
0
210
複数の Claude Code が"放置"されてしまう問題をCLI ダッシュボードを自作して解決した話
sumihiro3
1
670
関東Kaggler会_NVIDIA_Nemotron_コンペ_振り返り
rick_ds
0
490
Japan Community Day at Kubecon + CloudNativeCon Japan 2026: Learning Container Privilege Control by Building My Own Low-Level Container Runtime
ternbusty
1
150
夏だ!祭りだ!祭りとはドメインモデリングでは?
ryugen04
0
190
数百円から始めるRuby電子工作
tarosay
0
140
Welcome to the "Parametricity" 🏙️ − Generic だけど Specific な世界 −
guvalif
PRO
1
200
Featured
See All Featured
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
230
23k
The Invisible Side of Design
smashingmag
301
52k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
技術選定の審美眼(2025年版) / Understanding the Spiral of Technologies 2025 edition
twada
PRO
119
120k
Bridging the Design Gap: How Collaborative Modelling removes blockers to flow between stakeholders and teams @FastFlow conf
baasie
0
640
Distributed Sagas: A Protocol for Coordinating Microservices
caitiem20
333
23k
Navigating Weather and Climate Data
rabernat
0
460
RailsConf & Balkan Ruby 2019: The Past, Present, and Future of Rails at GitHub
eileencodes
141
35k
The Impact of AI in SEO - AI Overviews June 2024 Edition
aleyda
5
1.2k
Chrome DevTools: State of the Union 2024 - Debugging React & Beyond
addyosmani
10
1.3k
HDC tutorial
michielstock
2
790
Chasing Engaging Ingredients in Design
codingconduct
0
260
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༵