Permalink
Browse files

Partial revert of 2681685 premature TypeArray abstraction

  • Loading branch information...
1 parent 47cd8b8 commit f388725bd61d8ae246c0c8e42eaec1a2be4620ac @josh josh committed Aug 21, 2008
@@ -1,5 +1,5 @@
module ActionView #:nodoc:
- class PathSet < ActiveSupport::TypedArray #:nodoc:
+ class PathSet < Array #:nodoc:
def self.type_cast(obj)
if obj.is_a?(String)
if Base.warn_cache_misses && defined?(Rails) && Rails.initialized?
@@ -15,6 +15,30 @@ def self.type_cast(obj)
end
end
+ def initialize(*args)
+ super(*args).map! { |obj| self.class.type_cast(obj) }
+ end
+
+ def <<(obj)
+ super(self.class.type_cast(obj))
+ end
+
+ def concat(array)
+ super(array.map! { |obj| self.class.type_cast(obj) })
+ end
+
+ def insert(index, obj)
+ super(index, self.class.type_cast(obj))
+ end
+
+ def push(*objs)
+ super(*objs.map { |obj| self.class.type_cast(obj) })
+ end
+
+ def unshift(*objs)
+ super(*objs.map { |obj| self.class.type_cast(obj) })
+ end
+
class Path #:nodoc:
def self.eager_load_templates!
@eager_load_templates = true
@@ -39,7 +39,6 @@
require 'active_support/dependencies'
require 'active_support/deprecation'
-require 'active_support/typed_array'
require 'active_support/ordered_hash'
require 'active_support/ordered_options'
require 'active_support/option_merger'
@@ -1,31 +0,0 @@
-module ActiveSupport
- class TypedArray < Array
- def self.type_cast(obj)
- obj
- end
-
- def initialize(*args)
- super(*args).map! { |obj| self.class.type_cast(obj) }
- end
-
- def <<(obj)
- super(self.class.type_cast(obj))
- end
-
- def concat(array)
- super(array.map! { |obj| self.class.type_cast(obj) })
- end
-
- def insert(index, obj)
- super(index, self.class.type_cast(obj))
- end
-
- def push(*objs)
- super(*objs.map { |obj| self.class.type_cast(obj) })
- end
-
- def unshift(*objs)
- super(*objs.map { |obj| self.class.type_cast(obj) })
- end
- end
-end
@@ -1,51 +0,0 @@
-require 'abstract_unit'
-
-class TypedArrayTest < Test::Unit::TestCase
- class StringArray < ActiveSupport::TypedArray
- def self.type_cast(obj)
- obj.to_s
- end
- end
-
- def setup
- @array = StringArray.new
- end
-
- def test_string_array_initialize
- assert_equal ["1", "2", "3"], StringArray.new([1, "2", :"3"])
- end
-
- def test_string_array_append
- @array << 1
- @array << "2"
- @array << :"3"
- assert_equal ["1", "2", "3"], @array
- end
-
- def test_string_array_concat
- @array.concat([1, "2"])
- @array.concat([:"3"])
- assert_equal ["1", "2", "3"], @array
- end
-
- def test_string_array_insert
- @array.insert(0, 1)
- @array.insert(1, "2")
- @array.insert(2, :"3")
- assert_equal ["1", "2", "3"], @array
- end
-
- def test_string_array_push
- @array.push(1)
- @array.push("2")
- @array.push(:"3")
- assert_equal ["1", "2", "3"], @array
- end
-
- def test_string_array_unshift
- @array.unshift(:"3")
- @array.unshift("2")
- @array.unshift(1)
- assert_equal ["1", "2", "3"], @array
- end
-end

0 comments on commit f388725

Please sign in to comment.