Sha256: a04693c91872a5d4e4366dcfeb60a34475fae800f8242e6eab03fd6a27193e9e

Contents?: true

Size: 849 Bytes

Versions: 1

Compression:

Stored size: 849 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
  end
end

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
arel_toolkit-0.3.0 lib/arel/extensions/trim.rb