Sha256: ad977c4577c9f26761770400dd12cb5dd51aaacb6d95b60293765c8a4a72e7c4

Contents?: true

Size: 1.37 KB

Versions: 3

Compression:

Stored size: 1.37 KB

Contents

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

module Arel
  module Nodes
    # https://www.postgresql.org/docs/10/functions-string.html
    inheritance_class = if Gem.loaded_specs['activerecord'].version < Gem::Version.new('6.1.0')
                          Arel::Nodes::Node
                        else
                          Arel::Nodes::InfixOperation
                        end

    class Overlaps < inheritance_class
      attr_reader :start1
      attr_reader :end1
      attr_reader :start2
      attr_reader :end2

      def initialize(start1, end1, start2, end2)
        @start1 = start1
        @end1 = end1
        @start2 = start2
        @end2 = end2
      end
    end
  end

  module Visitors
    class ToSql
      def visit_Arel_Nodes_Overlaps(o, collector)
        collector << '('
        visit o.start1, collector
        collector << ', '
        visit o.end1, collector
        collector << ') OVERLAPS ('
        visit o.start2, collector
        collector << ', '
        visit o.end2, collector
        collector << ')'
      end
    end

    class Dot
      def visit_Arel_Nodes_Overlaps(o)
        visit_edge o, 'start1'
        visit_edge o, 'end1'
        visit_edge o, 'start2'
        visit_edge o, 'end2'
      end
    end
  end
end

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

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
arel_toolkit-0.4.9 lib/arel/extensions/overlaps.rb
arel_toolkit-0.4.8 lib/arel/extensions/overlaps.rb
arel_toolkit-0.4.7 lib/arel/extensions/overlaps.rb