Sha256: d79d87bb1a47ce49d0894770ef61f7726e7bf53b3595d79037235b9a895e2f29

Contents?: true

Size: 821 Bytes

Versions: 7

Compression:

Stored size: 821 Bytes

Contents

module ROM
  module SQL
    # @api private
    class DSL < BasicObject
      # @api private
      attr_reader :schema

      # @api private
      def initialize(schema)
        @schema = schema
      end

      # @api private
      def call(&block)
        result = instance_exec(&block)

        if result.is_a?(::Array)
          result
        else
          [result]
        end
      end

      # @api private
      def respond_to_missing?(name, include_private = false)
        super || schema.key?(name)
      end

      private

      # @api private
      def type(identifier)
        type_name = ::Dry::Core::Inflector.classify(identifier)
        types.const_get(type_name) if types.const_defined?(type_name)
      end

      # @api private
      def types
        ::ROM::SQL::Types
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

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