Sha256: 75e7c9335778ce704b745f9473d5cb3a6f9f4ab2213617584ab50a04aa21511d

Contents?: true

Size: 723 Bytes

Versions: 7

Compression:

Stored size: 723 Bytes

Contents

require 'rom/sql/dsl'
require 'rom/sql/function'

module ROM
  module SQL
    # @api private
    class ProjectionDSL < DSL
      # @api public
      def `(value)
        expr = ::Sequel.lit(value)
        ::ROM::SQL::Attribute.new(type(:string)).meta(sql_expr: expr)
      end

      # @api private
      def respond_to_missing?(name, include_private = false)
        super || type(name)
      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
            super
          end
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

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