aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/values
diff options
context:
space:
mode:
authorJon Leighton <j@jonathanleighton.com>2011-08-16 02:42:30 +0100
committerJon Leighton <j@jonathanleighton.com>2011-08-16 02:42:30 +0100
commit0d3615f04c79f6e90d8ab33fdfc920b8faac9cb8 (patch)
treed4b26f037bb3d8f190c42690c37e531eaf63ffee /activesupport/lib/active_support/values
parentf76842f57e3f4e9292867a456abd90c034230916 (diff)
downloadrails-0d3615f04c79f6e90d8ab33fdfc920b8faac9cb8.tar.gz
rails-0d3615f04c79f6e90d8ab33fdfc920b8faac9cb8.tar.bz2
rails-0d3615f04c79f6e90d8ab33fdfc920b8faac9cb8.zip
Fix tzinfo require (it broke test_raises_when_an_invalid_timezone_is_defined_in_the_config in railties)
Diffstat (limited to 'activesupport/lib/active_support/values')
-rw-r--r--activesupport/lib/active_support/values/time_zone.rb19
1 files changed, 13 insertions, 6 deletions
diff --git a/activesupport/lib/active_support/values/time_zone.rb b/activesupport/lib/active_support/values/time_zone.rb
index 323d5d3df7..4fb487ade1 100644
--- a/activesupport/lib/active_support/values/time_zone.rb
+++ b/activesupport/lib/active_support/values/time_zone.rb
@@ -195,12 +195,8 @@ module ActiveSupport
# (GMT). Seconds were chosen as the offset unit because that is the unit that
# Ruby uses to represent time zone offsets (see Time#utc_offset).
def initialize(name, utc_offset = nil, tzinfo = nil)
- begin
- require 'tzinfo'
- rescue LoadError => e
- $stderr.puts "You don't have tzinfo installed in your application. Please add it to your Gemfile and run bundle install"
- raise e
- end
+ self.class.send(:require_tzinfo)
+
@name = name
@utc_offset = utc_offset
@tzinfo = tzinfo || TimeZone.find_tzinfo(name)
@@ -372,6 +368,15 @@ module ActiveSupport
@us_zones ||= all.find_all { |z| z.name =~ /US|Arizona|Indiana|Hawaii|Alaska/ }
end
+ protected
+
+ def require_tzinfo
+ require 'tzinfo'
+ rescue LoadError
+ $stderr.puts "You don't have tzinfo installed in your application. Please add it to your Gemfile and run bundle install"
+ raise
+ end
+
private
def lookup(name)
@@ -379,6 +384,8 @@ module ActiveSupport
end
def lazy_zones_map
+ require_tzinfo
+
@lazy_zones_map ||= Hash.new do |hash, place|
hash[place] = create(place) if MAPPING.has_key?(place)
end