Sha256: 88988ac08ae29103610c99a6a9e97efe38f50e76ce0b4ae2341fa52f5e374bfb

Contents?: true

Size: 1011 Bytes

Versions: 10

Compression:

Stored size: 1011 Bytes

Contents

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

module Arel
  module Nodes
    # https://www.postgresql.org/docs/10/functions-string.html
    class Trim < Arel::Nodes::Node
      attr_reader :type
      attr_reader :substring
      attr_reader :string

      def initialize(type, substring, string)
        @type = type
        @substring = substring
        @string = string
      end
    end
  end

  module Visitors
    class ToSql
      def visit_Arel_Nodes_Trim(o, collector)
        collector << "trim(#{o.type} "
        if o.substring
          visit o.substring, collector
          collector << ' from '
        end
        visit o.string, collector
        collector << ')'
      end
    end

    class Dot
      def visit_Arel_Nodes_Trim(o)
        visit_edge o, 'type'
        visit_edge o, 'substring'
        visit_edge o, 'string'
      end
    end
  end
end

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

Version data entries

10 entries across 10 versions & 1 rubygems

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