aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2009-11-08 21:55:43 -0800
committerJeremy Kemper <jeremy@bitsweat.net>2009-11-08 22:02:57 -0800
commit20cdaddfd27dfeef5c853e85fafa4e13b6da05f3 (patch)
tree6a102d87cb71ac8fbc7dafeee2ed7e185d68b90d /activesupport/lib
parent7ad461b44dabb586fbad190493ac4ecd96104597 (diff)
downloadrails-20cdaddfd27dfeef5c853e85fafa4e13b6da05f3.tar.gz
rails-20cdaddfd27dfeef5c853e85fafa4e13b6da05f3.tar.bz2
rails-20cdaddfd27dfeef5c853e85fafa4e13b6da05f3.zip
Ruby 1.9.2: work around changes to flatten and nil.to_str
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/cache.rb3
-rw-r--r--activesupport/lib/active_support/core_ext/hash/conversions.rb3
-rw-r--r--activesupport/lib/active_support/dependencies.rb2
-rw-r--r--activesupport/lib/active_support/deprecated_callbacks.rb5
-rw-r--r--activesupport/lib/active_support/json/backends/jsongem.rb21
5 files changed, 20 insertions, 14 deletions
diff --git a/activesupport/lib/active_support/cache.rb b/activesupport/lib/active_support/cache.rb
index b91ae65e9f..2f714c62ee 100644
--- a/activesupport/lib/active_support/cache.rb
+++ b/activesupport/lib/active_support/cache.rb
@@ -43,7 +43,8 @@ module ActiveSupport
# ActiveSupport::Cache.lookup_store(MyOwnCacheStore.new)
# # => returns MyOwnCacheStore.new
def self.lookup_store(*store_option)
- store, *parameters = *([ store_option ].flatten)
+ store = store_option.shift
+ parameters = store_option
case store
when Symbol
diff --git a/activesupport/lib/active_support/core_ext/hash/conversions.rb b/activesupport/lib/active_support/core_ext/hash/conversions.rb
index 190173f8a0..35ccec5df4 100644
--- a/activesupport/lib/active_support/core_ext/hash/conversions.rb
+++ b/activesupport/lib/active_support/core_ext/hash/conversions.rb
@@ -1,4 +1,5 @@
require 'active_support/time'
+require 'active_support/core_ext/array/wrap'
require 'active_support/core_ext/hash/reverse_merge'
class Hash
@@ -138,7 +139,7 @@ class Hash
case value.class.to_s
when 'Hash'
if value['type'] == 'array'
- child_key, entries = value.detect { |k,v| k != 'type' } # child_key is throwaway
+ child_key, entries = Array.wrap(value.detect { |k,v| k != 'type' }) # child_key is throwaway
if entries.nil? || (c = value['__content__'] && c.blank?)
[]
else
diff --git a/activesupport/lib/active_support/dependencies.rb b/activesupport/lib/active_support/dependencies.rb
index 7f6f012721..e858bcdc80 100644
--- a/activesupport/lib/active_support/dependencies.rb
+++ b/activesupport/lib/active_support/dependencies.rb
@@ -339,7 +339,7 @@ module ActiveSupport #:nodoc:
next
end
[ nesting_camel ]
- end.flatten.compact.uniq
+ end.compact.flatten.compact.uniq
end
# Search for a file in load_paths matching the provided suffix.
diff --git a/activesupport/lib/active_support/deprecated_callbacks.rb b/activesupport/lib/active_support/deprecated_callbacks.rb
index 20fb03cbeb..f56fef0b6d 100644
--- a/activesupport/lib/active_support/deprecated_callbacks.rb
+++ b/activesupport/lib/active_support/deprecated_callbacks.rb
@@ -1,4 +1,5 @@
require 'active_support/core_ext/array/extract_options'
+require 'active_support/core_ext/array/wrap'
module ActiveSupport
# Callbacks are hooks into the lifecycle of an object that allow you to trigger logic
@@ -194,8 +195,8 @@ module ActiveSupport
end
def should_run_callback?(*args)
- [options[:if]].flatten.compact.all? { |a| evaluate_method(a, *args) } &&
- ![options[:unless]].flatten.compact.any? { |a| evaluate_method(a, *args) }
+ Array.wrap(options[:if]).flatten.compact.all? { |a| evaluate_method(a, *args) } &&
+ !Array.wrap(options[:unless]).flatten.compact.any? { |a| evaluate_method(a, *args) }
end
end
diff --git a/activesupport/lib/active_support/json/backends/jsongem.rb b/activesupport/lib/active_support/json/backends/jsongem.rb
index c6c17a3c4e..cfe28d7bb9 100644
--- a/activesupport/lib/active_support/json/backends/jsongem.rb
+++ b/activesupport/lib/active_support/json/backends/jsongem.rb
@@ -23,15 +23,18 @@ module ActiveSupport
private
def convert_dates_from(data)
case data
- when DATE_REGEX
- DateTime.parse(data)
- when Array
- data.map! { |d| convert_dates_from(d) }
- when Hash
- data.each do |key, value|
- data[key] = convert_dates_from(value)
- end
- else data
+ when nil
+ nil
+ when DATE_REGEX
+ DateTime.parse(data)
+ when Array
+ data.map! { |d| convert_dates_from(d) }
+ when Hash
+ data.each do |key, value|
+ data[key] = convert_dates_from(value)
+ end
+ else
+ data
end
end
end