Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save walf443/3089 to your computer and use it in GitHub Desktop.
Save walf443/3089 to your computer and use it in GitHub Desktop.
diff --git a/lib/jpmobile/mobile/abstract_mobile.rb b/lib/jpmobile/mobile/abstract_mobile.rb
index bdbaa13..2f88f11 100644
--- a/lib/jpmobile/mobile/abstract_mobile.rb
+++ b/lib/jpmobile/mobile/abstract_mobile.rb
@@ -48,6 +48,16 @@ module Jpmobile::Mobile
return false
end
+ # XXX: lib/jpmobile.rbのautoloadで先に各キャリアの定数を定義してるからできるよ
+ Jpmobile::Mobile.constants.each do |career|
+ career_class = Jpmobile::Mobile.const_get(career)
+ next if self == career_class
+
+ define_method "#{career.downcase}?" do
+ self.is_a?(career_class)
+ end
+ end
+
private
# リクエストのパラメータ。
def params
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment