lib/jinx/helpers/array.rb in jinx-2.1.1 vs lib/jinx/helpers/array.rb in jinx-2.1.2
- old
+ new
@@ -2,11 +2,11 @@
class Array
# The EMPTY_ARRAY constant is an immutable empty array, used primarily as a default argument.
class << EMPTY_ARRAY ||= Array.new
def <<(value)
- Jinx.fail(NotImplementedError, "Modification of the constant empty array is not supported")
+ raise NotImplementedError.new("Modification of the constant empty array is not supported")
end
end
# Relaxes the Ruby Array methods which take an Array argument to allow collection Enumerable arguments.
[:|, :+, :-, :&].each do |meth|
@@ -62,11 +62,11 @@
# [[:a, 1], [:b, 2, 3], [:c], []].to_assoc_hash #=> { :a => 1, :b => [2,3], :c => nil }
# @return [Hash] the first => rest hash
def to_assoc_hash
hash = {}
each do |item|
- Jinx.fail(ArgumentError, "Array member must be an array: #{item.pp_s(:single_line)}") unless Array === item
+ raise ArgumentError.new("Array member must be an array: #{item.pp_s(:single_line)}") unless Array === item
key = item.first
if item.size < 2 then
value = nil
elsif item.size == 2 then
value = item[1]
@@ -98,10 +98,10 @@
begin
add_all(other.to_a)
rescue NoMethodError
raise e
rescue
- Jinx.fail(ArgumentError, "Can't convert #{other.class.name} to array")
+ raise ArgumentError.new("Can't convert #{other.class.name} to array")
end
end
alias :merge! :add_all
end