Sha256: 85356705ace6723ca88acb0c743810e08435681a32fa0914823aecc64b8a1761

Contents?: true

Size: 950 Bytes

Versions: 15

Compression:

Stored size: 950 Bytes

Contents

module Arel
  class UpdateManager < Arel::TreeManager
    def initialize
      super
      @ast = Nodes::UpdateStatement.new
      @ctx = @ast
    end

    def take limit
      @ast.limit = Nodes::Limit.new(Nodes.build_quoted(limit)) if limit
      self
    end

    def key= key
      @ast.key = Nodes.build_quoted(key)
    end

    def key
      @ast.key
    end

    def order *expr
      @ast.orders = expr
      self
    end

    ###
    # UPDATE +table+
    def table table
      @ast.relation = table
      self
    end

    def wheres= exprs
      @ast.wheres = exprs
    end

    def where expr
      @ast.wheres << expr
      self
    end

    def set values
      if String === values
        @ast.values = [values]
      else
        @ast.values = values.map { |column,value|
          Nodes::Assignment.new(
            Nodes::UnqualifiedColumn.new(column),
            value
          )
        }
      end
      self
    end
  end
end

Version data entries

15 entries across 15 versions & 4 rubygems

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