Skip to content

Instantly share code, notes, and snippets.

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