Sha256: ff464ac1db1c18c5f7c3963715b930615fd0f11599acca65adf7f1eca3171504

Contents?: true

Size: 467 Bytes

Versions: 12

Compression:

Stored size: 467 Bytes

Contents

class Array
  # Standard in Ruby 1.9. See official documentation[http://ruby-doc.org/core-1.9/classes/Array.html]
  class << self
    # Try to convert obj into an array, using to_ary method.
    # Returns converted array or nil if obj cannot be converted
    # for any reason. This method is to check if an argument is an array.
    def try_convert(obj)
      return nil unless obj.respond_to?(:to_ary)
      Backports.coerce_to(obj, Array, :to_ary)
    end
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
marcandre-backports-1.8.0 lib/backports/1.9/array.rb
marcandre-backports-1.8.1 lib/backports/1.9/array.rb
marcandre-backports-1.8.2 lib/backports/1.9/array.rb
marcandre-backports-1.8.3 lib/backports/1.9/array.rb
marcandre-backports-1.8.4 lib/backports/1.9/array.rb
marcandre-backports-1.9.0 lib/backports/1.9/array.rb
backports-1.8.3 lib/backports/1.9/array.rb
backports-1.9.0 lib/backports/1.9/array.rb
backports-1.8.4 lib/backports/1.9/array.rb
backports-1.8.0 lib/backports/1.9/array.rb
backports-1.8.2 lib/backports/1.9/array.rb
backports-1.8.1 lib/backports/1.9/array.rb