Sha256: bf48f49c66ca7d7686af26d0f80e032b61f414cace96cb269afc567aa31b7cc0

Contents?: true

Size: 903 Bytes

Versions: 1

Compression:

Stored size: 903 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

1 entries across 1 versions & 1 rubygems

Version Path
rom-0.5.0 lib/rom/commands/update.rb