Sha256: 2f96c6eff50e0bdea906d7cf587398093799d7be17cfad873a8daafe8c86df04

Contents?: true

Size: 873 Bytes

Versions: 3

Compression:

Stored size: 873 Bytes

Contents

require 'rom/commands/with_options'

module ROM
  module Commands

    # Update command
    #
    # This command updates all tuples in its relation with new attributes
    #
    # @abstract
    class Update < AbstractCommand
      include WithOptions

      alias_method :set, :call

      # @see AbstractCommand#call
      def call(*args)
        assert_tuple_count
        super
      end

      # Execute the update command
      #
      # @return [Array] an array with updated tuples
      #
      # @abstract
      #
      # @api private
      def execute(params)
        raise NotImplementedError, "#{self.class}##{__method__} must be implemented"
      end

      # Return new update command with new relation
      #
      # @api private
      def new(*args, &block)
        self.class.new(relation.public_send(*args, &block), options)
      end
    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rom-0.4.2 lib/rom/commands/update.rb
rom-0.4.1 lib/rom/commands/update.rb
rom-0.4.0 lib/rom/commands/update.rb