Sha256: eda2b8c8303ea90214bb847bfd3bd9b00184a570cd7a46096d6eb63a4eff2ccf

Contents?: true

Size: 765 Bytes

Versions: 5

Compression:

Stored size: 765 Bytes

Contents

module Basket
  module Batcher
    def self.included(base)
      base.extend(ClassMethods)
    end

    module ClassMethods
      def basket_options(args)
        @basket_options = args
      end

      def basket_options_hash
        raise Basket::Error, "You must specify the size of your basket!" if @basket_options.nil?
        raise Basket::Error, "You must specify a size greater than 0" if @basket_options[:size] <= 0

        @basket_options
      end
    end

    def batch
      @batch ||= Basket.queue_collection.read(self.class.name)
    end

    def perform
      raise Basket::Error, "You must implement perform in your Basket class."
    end

    def on_success
    end

    def on_add
    end

    def on_failure
      raise error
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
basket-0.0.7 lib/basket/batcher.rb
basket-0.0.6 lib/basket/batcher.rb
basket-0.0.5 lib/basket/batcher.rb
basket-0.0.4 lib/basket/batcher.rb
basket-0.0.3 lib/basket/batcher.rb