aboutsummaryrefslogblamecommitdiffstats
path: root/activesupport/lib/active_support/typed_array.rb
blob: 1a4d8a8faf7eaf71f3a87852b5a0c59d5a0a8af0 (plain) (tree)






























                                                           
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