Sha256: 047df09b554a4b809509cdb2ec44f2a8ab32012528fd26a66113215d5123a220

Contents?: true

Size: 914 Bytes

Versions: 8

Compression:

Stored size: 914 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)
        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

8 entries across 8 versions & 1 rubygems

Version Path
arel_toolkit-0.4.7 lib/arel/extensions/type_cast.rb
arel_toolkit-0.4.6 lib/arel/extensions/type_cast.rb
arel_toolkit-0.4.5 lib/arel/extensions/type_cast.rb
arel_toolkit-0.4.4 lib/arel/extensions/type_cast.rb
arel_toolkit-0.4.3 lib/arel/extensions/type_cast.rb
arel_toolkit-0.4.2 lib/arel/extensions/type_cast.rb
arel_toolkit-0.4.1 lib/arel/extensions/type_cast.rb
arel_toolkit-0.4.0 lib/arel/extensions/type_cast.rb