Sha256: 7cb8d97822e22c00a72cf9c77d429d3500da98428fdfa863c6ba9b72444abdd0

Contents?: true

Size: 367 Bytes

Versions: 73

Compression:

Stored size: 367 Bytes

Contents

module Enumerable
  # Standard in rails... See official documentation[http://api.rubyonrails.org/classes/Enumerable.html]
  # Modified from rails 2.3 to not rely on size
  def sum(identity = 0, &block)
    if block_given?
      map(&block).sum(identity)
    else
      inject { |sum, element| sum + element } || identity
    end
  end unless method_defined? :sum

end

Version data entries

73 entries across 73 versions & 3 rubygems

Version Path
backports-1.11.2 lib/backports/rails/enumerable.rb
backports-1.11.1 lib/backports/rails/enumerable.rb
backports-1.11.0 lib/backports/rails/enumerable.rb
backports-1.10.3 lib/backports/rails/enumerable.rb
backports-1.10.2 lib/backports/rails/enumerable.rb
backports-1.10.1 lib/backports/rails/enumerable.rb
backports-1.10.0 lib/backports/rails/enumerable.rb
backports-1.9.0 lib/backports/rails/enumerable.rb
backports-1.8.3 lib/backports/rails/enumerable.rb
backports-1.8.4 lib/backports/rails/enumerable.rb
backports-1.8.2 lib/backports/rails/enumerable.rb
backports-1.8.1 lib/backports/rails/enumerable.rb
backports-1.8.0 lib/backports/rails/enumerable.rb