Sha256: 99138316b811eff56e5f1ec05635d9ba0c7036b6777cdc4abfc14834688d0cd4

Contents?: true

Size: 754 Bytes

Versions: 6

Compression:

Stored size: 754 Bytes

Contents

require 'rom/sql/dsl'

module ROM
  module SQL
    # @api private
    class RestrictionDSL < DSL
      # @api private
      def call(&block)
        instance_exec(&block)
      end

      # Returns a result of SQL EXISTS clause.
      #
      # @example
      #   users.where { exists(users.where(name: 'John')) }
      def exists(relation)
        relation.dataset.exists
      end

      private

      # @api private
      def method_missing(meth, *args, &block)
        if schema.key?(meth)
          schema[meth]
        else
          type = type(meth)

          if type
            ::ROM::SQL::Function.new(type)
          else
            ::Sequel::VIRTUAL_ROW.__send__(meth, *args, &block)
          end
        end
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rom-sql-1.3.5 lib/rom/sql/restriction_dsl.rb
rom-sql-1.3.4 lib/rom/sql/restriction_dsl.rb
rom-sql-2.0.0.beta3 lib/rom/sql/restriction_dsl.rb
rom-sql-2.0.0.beta2 lib/rom/sql/restriction_dsl.rb
rom-sql-2.0.0.beta1 lib/rom/sql/restriction_dsl.rb
rom-sql-1.3.3 lib/rom/sql/restriction_dsl.rb