Sha256: ae93cb710433edccdc75c47067945cf94a81f7f5f4b746b1910b9a71c5bcf308

Contents?: true

Size: 828 Bytes

Versions: 3

Compression:

Stored size: 828 Bytes

Contents

# frozen_string_literal: true

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
      %i[where all first last each record_limit scan_limit batch start scan_index_forward find_by_pages project].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, &blk|
          chain = Dynamoid::Criteria::Chain.new(self)
          if args
            chain.send(meth, *args, &blk)
          else
            chain.send(meth, &blk)
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dynamoid-3.4.1 lib/dynamoid/criteria.rb
dynamoid-3.4.0 lib/dynamoid/criteria.rb
dynamoid-3.3.0 lib/dynamoid/criteria.rb