Sha256: eb5a0a380e1df683702b0a1c909c2ae00694bf4167147fca93199f081bc826f8

Contents?: true

Size: 735 Bytes

Versions: 3

Compression:

Stored size: 735 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, :each].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

3 entries across 3 versions & 1 rubygems

Version Path
dynamoid-0.3.2 lib/dynamoid/criteria.rb
dynamoid-0.3.1 lib/dynamoid/criteria.rb
dynamoid-0.3.0 lib/dynamoid/criteria.rb