Sha256: 7cbc14214b450a8f1c9614b01bf4bbcf45483bb67496acd682bc99d679789937

Contents?: true

Size: 917 Bytes

Versions: 17

Compression:

Stored size: 917 Bytes

Contents

module Arel
  module Nodes
    class Function < Arel::Nodes::Node
      include Arel::Predications
      include Arel::WindowPredications
      include Arel::OrderPredications
      attr_accessor :expressions, :alias, :distinct

      def initialize expr, aliaz = nil
        super()
        @expressions = expr
        @alias       = aliaz && SqlLiteral.new(aliaz)
        @distinct    = false
      end

      def as aliaz
        self.alias = SqlLiteral.new(aliaz)
        self
      end

      def hash
        [@expressions, @alias, @distinct].hash
      end

      def eql? other
        self.class == other.class &&
          self.expressions == other.expressions &&
          self.alias == other.alias &&
          self.distinct == other.distinct
      end
    end

    %w{
      Sum
      Exists
      Max
      Min
      Avg
    }.each do |name|
      const_set(name, Class.new(Function))
    end
  end
end

Version data entries

17 entries across 16 versions & 4 rubygems

Version Path
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/arel-6.0.4/lib/arel/nodes/function.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/arel-7.1.4/lib/arel/nodes/function.rb
autocompl-0.2.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/arel-7.1.4/lib/arel/nodes/function.rb
autocompl-0.2.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/arel-7.1.4/lib/arel/nodes/function.rb
autocompl-0.2.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/arel-7.1.4/lib/arel/nodes/function.rb
autocompl-0.1.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/arel-7.1.4/lib/arel/nodes/function.rb
autocompl-0.1.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/arel-7.1.4/lib/arel/nodes/function.rb
autocompl-0.1.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/arel-7.1.4/lib/arel/nodes/function.rb
autocompl-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/arel-7.1.4/lib/arel/nodes/function.rb
abaci-0.3.0 vendor/bundle/gems/arel-7.1.0/lib/arel/nodes/function.rb
arel-6.0.4 lib/arel/nodes/function.rb
arel-7.1.4 lib/arel/nodes/function.rb
arel-7.1.3 lib/arel/nodes/function.rb
arel-7.1.2 lib/arel/nodes/function.rb
arel-7.1.1 lib/arel/nodes/function.rb
arel-7.1.0 lib/arel/nodes/function.rb
arel-7.0.0 lib/arel/nodes/function.rb