Sha256: a422ea57824f189d9c48f07b07500618b34e74e960214ecda27815cafa142751

Contents?: true

Size: 989 Bytes

Versions: 74

Compression:

Stored size: 989 Bytes

Contents

module Cash
  module Query
    class Calculation < Abstract
      delegate :calculate_without_cache, :incr, :to => :@active_record

      def initialize(active_record, operation, column, options1, options2)
        super(active_record, options1, options2)
        @operation, @column = operation, column
      end

      def perform
        super({}, :raw => true)
      end

      def calculation?
        true
      end

      protected
      def miss(_, __)
        calculate_without_cache(@operation, @column, @options1)
      end

      def uncacheable
        calculate_without_cache(@operation, @column, @options1)
      end

      def format_results(_, objects)
        objects.to_i
      end

      def serialize_objects(_, objects)
        objects.to_s
      end

      def cacheable?(*optionss)
        @column == :all && super(*optionss)
      end

      def cache_keys(attribute_value_pairs)
        "#{super(attribute_value_pairs)}/#{@operation}"
      end
    end
  end
end

Version data entries

74 entries across 74 versions & 22 rubygems

Version Path
ashleym1972-cache-money-0.2.5.1 lib/cash/query/calculation.rb
ashleym1972-cache-money-0.2.6 lib/cash/query/calculation.rb
ashleym1972-cache-money-0.2.7 lib/cash/query/calculation.rb
ashleym1972-cache-money-0.2.8 lib/cash/query/calculation.rb
ashleym1972-cache-money-0.2.9 lib/cash/query/calculation.rb
deedubs-cache-money-0.2.5 lib/cash/query/calculation.rb
factorylabs-cache-money-0.2.5 lib/cash/query/calculation.rb
factorylabs-cache-money-0.2.6 lib/cash/query/calculation.rb
factorylabs-cache-money-0.2.7 lib/cash/query/calculation.rb
factorylabs-cache-money-0.2.8 lib/cash/query/calculation.rb
netshade-cache-money-0.2.5.2 lib/cash/query/calculation.rb
netshade-cache-money-0.2.5.3 lib/cash/query/calculation.rb
netshade-cache-money-0.2.5.4 lib/cash/query/calculation.rb
netshade-cache-money-0.2.5.5 lib/cash/query/calculation.rb
nkallen-cache-money-0.2.1 lib/cash/query/calculation.rb
nkallen-cache-money-0.2.2 lib/cash/query/calculation.rb
nkallen-cache-money-0.2.3 lib/cash/query/calculation.rb
nkallen-cache-money-0.2.4 lib/cash/query/calculation.rb
nkallen-cache-money-0.2.5 lib/cash/query/calculation.rb
onyx-cache-money-0.2.5.1 lib/cash/query/calculation.rb