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