Sha256: c8ce3d97868dd20f2662f01ab19442e563ba77abc36995abd808403aa816d1dc

Contents?: true

Size: 759 Bytes

Versions: 3

Compression:

Stored size: 759 Bytes

Contents

# frozen_string_literal: true

require 'rom/sql/dsl'

module ROM
  module SQL
    # @api private
    class RestrictionDSL < DSL
      # @api private
      def call(&block)
        arg, kwargs = select_relations(block.parameters)

        if kwargs.nil?
          instance_exec(arg, &block)
        else
          instance_exec(**kwargs, &block)
        end
      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).meta(schema: schema)
          else
            ::Sequel::VIRTUAL_ROW.__send__(meth, *args, &block)
          end
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rom-sql-3.6.5 lib/rom/sql/restriction_dsl.rb
rom-sql-3.6.4 lib/rom/sql/restriction_dsl.rb
rom-sql-3.6.3 lib/rom/sql/restriction_dsl.rb