Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Changeset 8224

Show
Ignore:
Timestamp:
11/27/07 19:42:30 (9 months ago)
Author:
david
Message:

Added Array#from and Array#to that behaves just from String#from and String#to [DHH]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activesupport/CHANGELOG

    r8202 r8224  
    11*SVN* 
     2 
     3* Added Array#from and Array#to that behaves just from String#from and String#to [DHH] 
    24 
    35* Fix that empty collections should be treated as empty arrays regardless of whitespace for Hash#from_xml #10255 [adamj] 
  • trunk/activesupport/lib/active_support/core_ext/array.rb

    r7719 r8224  
     1require 'active_support/core_ext/array/access' 
    12require 'active_support/core_ext/array/conversions' 
    23require 'active_support/core_ext/array/extract_options' 
     
    56 
    67class Array #:nodoc: 
     8  include ActiveSupport::CoreExtensions::Array::Access 
    79  include ActiveSupport::CoreExtensions::Array::Conversions 
    810  include ActiveSupport::CoreExtensions::Array::ExtractOptions 
  • trunk/activesupport/test/core_ext/array_ext_test.rb

    r7486 r8224  
    11require File.dirname(__FILE__) + '/../abstract_unit' 
    22require 'bigdecimal' 
     3 
     4class ArrayExtAccessTests < Test::Unit::TestCase 
     5  def test_from 
     6    assert_equal %w( a b c d ), %w( a b c d ).from(0) 
     7    assert_equal %w( c d ), %w( a b c d ).from(2) 
     8    assert_nil %w( a b c d ).from(10) 
     9  end 
     10 
     11  def test_to 
     12    assert_equal %w( a ), %w( a b c d ).to(0) 
     13    assert_equal %w( a b c ), %w( a b c d ).to(2) 
     14    assert_equal %w( a b c d ), %w( a b c d ).to(10) 
     15  end 
     16end 
    317 
    418class ArrayExtToParamTests < Test::Unit::TestCase