Sha256: c9d59bd6973618e6ee8f9f8673afd7283fbdae112f1e59ccf39e1dabf7f00edd

Contents?: true

Size: 884 Bytes

Versions: 6

Compression:

Stored size: 884 Bytes

Contents

# frozen_string_literal: true

require 'dynamoid_advanced_where/query_builder'

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

      class_methods do
        def advanced_where(&blk)
          DynamoidAdvancedWhere::QueryBuilder.new(klass: self, &blk)
        end

        def batch_update
          advanced_where {}.batch_update
        end

        def where(*args, &blk)
          if !args.empty?
            raise ArgumentError, 'You may not specify where arguments and block' if blk

            super(*args)
          else
            DynamoidAdvancedWhere::QueryBuilder.new(klass: self, &blk)
          end
        end
      end
    end
  end
end

Dynamoid::Document.send(:include, DynamoidAdvancedWhere::Integrations::Model)

Version data entries

6 entries across 6 versions & 2 rubygems

Version Path
dynamoid_advanced_where-1.3.0 lib/dynamoid_advanced_where/integrations/model.rb
dynamoid_advanced_where-1.2.0 lib/dynamoid_advanced_where/integrations/model.rb
dynamoid_advanced_where-1.1.0 lib/dynamoid_advanced_where/integrations/model.rb
dynamoid_advanced_where-1.0.1 lib/dynamoid_advanced_where/integrations/model.rb
dynamoid_advanced_where-1.0.0 lib/dynamoid_advanced_where/integrations/model.rb
dynamoid-advanced-where-1.0.0 lib/dynamoid_advanced_where/integrations/model.rb