Sha256: 03fbf4f48438acceb5e0958559ac8c8904aa4245bc734b855293a3d8a27c4440

Contents?: true

Size: 943 Bytes

Versions: 2

Compression:

Stored size: 943 Bytes

Contents

# rubocop:disable Naming/MethodName
# rubocop:disable Naming/UncommunicativeMethodParamName

module Arel
  module Nodes
    # Postgres: https://www.postgresql.org/docs/9.1/sql-expressions.html
    class TypeCast < Arel::Nodes::Node
      attr_reader :arg
      attr_reader :type_name

      def initialize(arg, type_name)
        @arg = arg
        @type_name = type_name
      end

      def ==(other)
        self.class == other.class && arg == other.arg && type_name == other.type_name
      end
    end
  end

  module Visitors
    class ToSql
      def visit_Arel_Nodes_TypeCast(o, collector)
        visit o.arg, collector
        collector << '::'
        collector << o.type_name
      end
    end

    class Dot
      def visit_Arel_Nodes_TypeCast(o)
        visit_edge(o, 'arg')
        visit_edge(o, 'type_name')
      end
    end
  end
end

# rubocop:enable Naming/MethodName
# rubocop:enable Naming/UncommunicativeMethodParamName

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
arel_toolkit-0.4.9 lib/arel/extensions/type_cast.rb
arel_toolkit-0.4.8 lib/arel/extensions/type_cast.rb