Created
August 20, 2008 14:35
-
-
Save walf443/6378 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/lib/jpmobile.rb b/lib/jpmobile.rb | |
index 178ad7f..7e1e72d 100644 | |
--- a/lib/jpmobile.rb | |
+++ b/lib/jpmobile.rb | |
@@ -15,6 +15,14 @@ module Jpmobile | |
autoload :Emobile, 'jpmobile/mobile/emobile' | |
autoload :Willcom, 'jpmobile/mobile/willcom' | |
autoload :Ddipocket, 'jpmobile/mobile/willcom' | |
+ | |
+ def self.careers | |
+ @careers ||= constants | |
+ end | |
+ | |
+ def self.careers= ary | |
+ @careers = ary | |
+ end | |
end | |
end | |
diff --git a/lib/jpmobile/mobile/abstract_mobile.rb b/lib/jpmobile/mobile/abstract_mobile.rb | |
index b0dc783..1bdff5c 100644 | |
--- a/lib/jpmobile/mobile/abstract_mobile.rb | |
+++ b/lib/jpmobile/mobile/abstract_mobile.rb | |
@@ -49,7 +49,7 @@ module Jpmobile::Mobile | |
end | |
#XXX: lib/jpmobile.rbのautoloadで先に各キャリアの定数を定義しているから動くのです | |
- Jpmobile::Mobile.constants.each do |career| | |
+ Jpmobile::Mobile.careers.each do |career| | |
career_class = Jpmobile::Mobile.const_get(career) | |
next if career_class == self | |
diff --git a/lib/jpmobile/request_with_mobile.rb b/lib/jpmobile/request_with_mobile.rb | |
index e6f944c..46f119b 100644 | |
--- a/lib/jpmobile/request_with_mobile.rb | |
+++ b/lib/jpmobile/request_with_mobile.rb | |
@@ -33,7 +33,7 @@ module Jpmobile | |
def mobile | |
return @__mobile if @__mobile | |
- Jpmobile::Mobile.constants.each do |const| | |
+ Jpmobile::Mobile.careers.each do |const| | |
c = Jpmobile::Mobile.const_get(const) | |
return @__mobile = c.new(self) if c::USER_AGENT_REGEXP && user_agent =~ c::USER_AGENT_REGEXP | |
end | |
# on irb | |
require 'jpmobile' | |
#=> true | |
Jpmobile::Mobile.careers | |
#=> ["Au", "Jphone", "Docomo", "Ddipocket", "Vodafone", "Willcom", "Softbank", "AbstractMobile", "Emobile"] | |
Jpmobile::Mobile.careers = ["Au", "Jphone"] | |
#=> ["Au", "Jphone"] | |
Jpmobile::Mobile.careers | |
#=> ["Au", "Jphone"] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment