Sha256: b0278a7f3b145cbe8fb5af86d22b39ca5dd0417c5bb3f99c10e08e9bac2699a3

Contents?: true

Size: 890 Bytes

Versions: 10

Compression:

Stored size: 890 Bytes

Contents

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

module Arel
  module Nodes
    # https://www.postgresql.org/docs/9.4/functions-math.html
    class Factorial < Arel::Nodes::Node
      attr_accessor :prefix
      attr_accessor :expr

      def initialize(expr, prefix)
        @expr = expr
        @prefix = prefix
      end
    end
  end

  module Visitors
    class ToSql
      def visit_Arel_Nodes_Factorial(o, collector)
        if o.prefix
          collector << '!! '
          visit o.expr, collector
        else
          visit o.expr, collector
          collector << ' !'
        end
      end
    end

    class Dot
      def visit_Arel_Nodes_Factorial(o)
        visit_edge o, 'expr'
        visit_edge o, 'prefix'
      end
    end
  end
end

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

Version data entries

10 entries across 10 versions & 1 rubygems

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