Sha256: a9031441ff0faf46d0f22f8853a26a03dbd7a7a566fc99d3f94fc6020b86dab5

Contents?: true

Size: 1.29 KB

Versions: 10

Compression:

Stored size: 1.29 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

    class Dot
      def visit_Arel_Nodes_Overlay(o)
        visit_edge o, 'string'
        visit_edge o, 'substring'
        visit_edge o, 'start'
        visit_edge o, 'length'
      end
    end
  end
end

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

Version data entries

10 entries across 10 versions & 1 rubygems

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