Class: ROM::SQL::RestrictionDSL Private

Inherits:
DSL
  • Object
show all
Defined in:
lib/rom/sql/restriction_dsl.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Instance Attribute Summary

Attributes inherited from DSL

#relations, #schema

Instance Method Summary collapse

Methods inherited from DSL

#`, #initialize, #respond_to_missing?

Constructor Details

This class inherits a constructor from ROM::SQL::DSL

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &block) ⇒ Object (private)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/rom/sql/restriction_dsl.rb', line 23

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

Instance Method Details

#call(&block) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



8
9
10
# File 'lib/rom/sql/restriction_dsl.rb', line 8

def call(&block)
  instance_exec(relations, &block)
end

#exists(relation) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a result of SQL EXISTS clause.

Examples:

users.where { exists(users.where(name: 'John')) }


16
17
18
# File 'lib/rom/sql/restriction_dsl.rb', line 16

def exists(relation)
  ::ROM::SQL::Attribute[Types::Bool].meta(sql_expr: relation.dataset.exists)
end