Sha256: 6dba2af4c5682c9858087fee137344ec6e65071e16c4b34fd9fea9ec99156822

Contents?: true

Size: 743 Bytes

Versions: 1

Compression:

Stored size: 743 Bytes

Contents

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

module Arel
  module Nodes
    # https://www.postgresql.org/docs/9.1/functions-datetime.html#FUNCTIONS-DATETIME-EXTRACT
    class ExtractFrom < Arel::Nodes::Unary
      attr_reader :field

      def initialize(expr, field)
        super(expr)

        @field = field
      end
    end
  end

  module Visitors
    class ToSql
      def visit_Arel_Nodes_ExtractFrom(o, collector)
        collector << 'extract('
        visit o.field, collector
        collector << ' from '
        visit o.expr, 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/extract_from.rb