Sha256: 803592335b4546173f973c612c2d8326e028593357c1155d615b623a2a627297

Contents?: true

Size: 470 Bytes

Versions: 18

Compression:

Stored size: 470 Bytes

Contents

require 'backports/tools/deprecation'

Backports.deprecate :rails, 'Rails backports are deprecated.'

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

18 entries across 18 versions & 1 rubygems

Version Path
backports-3.25.0 lib/backports/rails/enumerable.rb
backports-3.24.1 lib/backports/rails/enumerable.rb
backports-3.24.0 lib/backports/rails/enumerable.rb
backports-3.23.0 lib/backports/rails/enumerable.rb
backports-3.22.1 lib/backports/rails/enumerable.rb
backports-3.22.0 lib/backports/rails/enumerable.rb
backports-3.21.0 lib/backports/rails/enumerable.rb
backports-3.20.2 lib/backports/rails/enumerable.rb
backports-3.20.1 lib/backports/rails/enumerable.rb
backports-3.20.0 lib/backports/rails/enumerable.rb
backports-3.19.0 lib/backports/rails/enumerable.rb
backports-3.18.2 lib/backports/rails/enumerable.rb
backports-3.18.1 lib/backports/rails/enumerable.rb
backports-3.18.0 lib/backports/rails/enumerable.rb
backports-3.17.2 lib/backports/rails/enumerable.rb
backports-3.17.1 lib/backports/rails/enumerable.rb
backports-3.17.0 lib/backports/rails/enumerable.rb
backports-3.16.1 lib/backports/rails/enumerable.rb