Sha256: 9874c07321fd983944a636f2702bfffc30fd05c39ee631785f36fca521026240

Contents?: true

Size: 395 Bytes

Versions: 6

Compression:

Stored size: 395 Bytes

Contents

# count_using :price
# count_using ->{ revenue * priority }
# This lets you keep running totals of revenue etc rather than just a count of the orders
module Counter::Summable
  extend ActiveSupport::Concern

  included do
    # Replace Increment#increment_from_item
    def increment_from_item item
      return item.send definition.column_to_count if definition.sum?

      1
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
counterwise-0.1.5 app/models/concerns/counter/summable.rb
counterwise-0.1.4 app/models/concerns/counter/summable.rb
counterwise-0.1.3 app/models/concerns/counter/summable.rb
counterwise-0.1.2 app/models/concerns/counter/summable.rb
counterwise-0.1.1 app/models/concerns/counter/summable.rb
counterwise-0.1.0 app/models/concerns/counter/summable.rb