Sha256: 24ff702bd407e29978e7089140d6f56d293af386002562645bf02b47c8919298

Contents?: true

Size: 835 Bytes

Versions: 4

Compression:

Stored size: 835 Bytes

Contents

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

module ROM
  module SQL
    # @api private
    class ProjectionDSL < DSL
      # @api private
      def respond_to_missing?(name, include_private = false)
        super || type(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

      # @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

4 entries across 4 versions & 1 rubygems

Version Path
rom-sql-1.0.1 lib/rom/sql/projection_dsl.rb
rom-sql-1.0.0 lib/rom/sql/projection_dsl.rb
rom-sql-1.0.0.rc2 lib/rom/sql/projection_dsl.rb
rom-sql-1.0.0.rc1 lib/rom/sql/projection_dsl.rb