Sha256: 4f7da565a9420e172aa44b0b75a0c117b760d6bc4de81bfb9b05b1ff5789decd

Contents?: true

Size: 909 Bytes

Versions: 3

Compression:

Stored size: 909 Bytes

Contents

module ROM
  module Commands

    # Delete command
    #
    # This command removes tuples from its target relation
    #
    # @abstract
    class Delete < AbstractCommand
      attr_reader :target

      def initialize(relation, options)
        super
        @target = options[:target] || relation
      end

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

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

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

    end

  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

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