Sha256: 667ff1e6d083f9e391ce9b999fa2ada076197f9785a0424a64e66dbb305a4a1d

Contents?: true

Size: 826 Bytes

Versions: 1

Compression:

Stored size: 826 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

      def respond_to_missing?(_meth, _include_private = false)
        true
      end

      # @api private
      def method_missing(meth, ...)
        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, ...)
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rom-sql-3.7.0 lib/rom/sql/restriction_dsl.rb