Sha256: 5ee8d5e1892915d4de38cdc6cdae2add2e541c2b0aca5136a7a94e1a86f89db2

Contents?: true

Size: 1.07 KB

Versions: 3

Compression:

Stored size: 1.07 KB

Contents

module Counter
  module Cache
    module Counters
      class BufferCounter
        class Enqueuer < Struct.new(:options, :source_object_class_name, :relation_id, :relation_class, :counter_class_name)
          def enqueue!(source_object)
            create_and_enqueue(options.wait(source_object), options.cached?)
            create_and_enqueue(options.recalculation_delay, false) if options.recalculation?
          end

          private

          def create_and_enqueue(delay, cached)
            options.worker_adapter.enqueue(delay,
                                           source_object_class_name,
                                           { relation_class_name: relation_class,
                                             relation_id: relation_id,
                                             column: options.column,
                                             method: options.method,
                                             cache: cached,
                                             counter: counter_class_name })
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
counter-cache-0.1.0 lib/counter/cache/counters/buffer_counter/enqueuer.rb
counter-cache-0.0.2 lib/counter/cache/counters/buffer_counter/enqueuer.rb
counter-cache-0.0.1 lib/counter/cache/counters/buffer_counter/enqueuer.rb