Sha256: 5ed7c13ae7c36c089b02306b274fc0620f8c09cc4eb5cef8188caf0c2a4b83b4

Contents?: true

Size: 795 Bytes

Versions: 4

Compression:

Stored size: 795 Bytes

Contents

# encoding: utf-8
require 'dynamoid/criteria/chain'

module Dynamoid

  # Allows classes to be queried by where, all, first, and each and return criteria chains.
  module Criteria
    extend ActiveSupport::Concern

    module ClassMethods

      [:where, :all, :first, :last, :each, :record_limit, :scan_limit, :batch, :start, :scan_index_forward].each do |meth|
        # Return a criteria chain in response to a method that will begin or end a chain. For more information,
        # see Dynamoid::Criteria::Chain.
        #
        # @since 0.2.0
        define_method(meth) do |*args|
          chain = Dynamoid::Criteria::Chain.new(self)
          if args
            chain.send(meth, *args)
          else
            chain.send(meth)
          end
        end
      end
    end
  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
dynamoid-2.2.0 lib/dynamoid/criteria.rb
dynamoid-2.1.0 lib/dynamoid/criteria.rb
dynamoid-2.0.0 lib/dynamoid/criteria.rb
dynamoid-1.3.4 lib/dynamoid/criteria.rb