Sha256: 90c897d1dd4f11a50e3964388fadd5d744da8f95718256e40c9a9c495197a919

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

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

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

      def initialize(string, substring, start, length = nil)
        @string = string
        @substring = substring
        @start = start
        @length = length
      end
    end
  end

  module Visitors
    class ToSql
      def visit_Arel_Nodes_Overlay(o, collector)
        collector << 'overlay('
        visit o.string, collector
        collector << ' placing '
        visit o.substring, collector
        collector << ' from '
        visit o.start, collector
        unless o.length.nil?
          collector << ' for '
          visit o.length, collector
        end
        collector << ')'
      end
    end
  end
end

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

Version data entries

1 entries across 1 versions & 1 rubygems

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