Sha256: 5b9629f89af493fa1fd6d8063398f1e562fc2102a17ac7a01befef9460d44b1a

Contents?: true

Size: 512 Bytes

Versions: 10

Compression:

Stored size: 512 Bytes

Contents

module Comable
  class Order < ActiveRecord::Base
    module Morrisable
      extend ActiveSupport::Concern

      module ClassMethods
        def morris_keys
          %w( count price )
        end

        def to_morris
          this = (Rails::VERSION::MAJOR == 3) ? scoped : all
          this.group_by { |order| order.completed_at.to_date }.map do |date, orders|
            { date: date, count: orders.count, price: orders.sum(&:total_price) }
          end.to_json
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
comable-core-0.7.1 app/models/comable/order/morrisable.rb
comable-core-0.7.0 app/models/comable/order/morrisable.rb
comable-core-0.7.0.beta2 app/models/comable/order/morrisable.rb
comable-core-0.7.0.beta1 app/models/comable/order/morrisable.rb
comable-core-0.6.0 app/models/comable/order/morrisable.rb
comable_core-0.5.0 app/models/comable/order/morrisable.rb
comable_core-0.4.2 app/models/comable/order/morrisable.rb
comable_core-0.4.1 app/models/comable/order/morrisable.rb
comable_core-0.4.0 app/models/comable/order/morrisable.rb
comable_core-0.3.4 app/models/comable/order/morrisable.rb