Permalink
Browse files

add AttachmentFu::Tasks#unqueue

  • Loading branch information...
1 parent 70af241 commit ce7e2e589a80da40b5067647ffaab3eb05571526 @technoweenie committed Dec 5, 2008
Showing with 23 additions and 0 deletions.
  1. +10 −0 lib/attachment_fu/tasks.rb
  2. +13 −0 spec/tasks_spec.rb
@@ -147,6 +147,16 @@ def load(key, options = {})
@all[key] = t
end
+ def unqueue(*keys)
+ tasks = keys.map do |key_or_index|
+ case key_or_index
+ when Symbol then @all[key_or_index]
+ when Fixnum then @stack[key_or_index]
+ end
+ end
+ @stack.delete_if { |(task, options)| tasks.include?(task) }
+ end
+
def key?(key_or_index)
case key_or_index
when Symbol then @all.key?(key_or_index)
View
@@ -49,6 +49,19 @@ module AttachmentFu
@tasks.queued?(:baz).should == false
end
+ it "allows unqueueuing of tasks" do
+ t = Tasks.new self do
+ load :foo
+ task :bar, :a => 1
+ task :bar, :a => 2
+ prepend :baz
+ unqueue :foo, :bar
+ end
+
+ t.size.should == 1
+ t[0].should == [t[:baz], {}]
+ end
+
it "allows tasks to be copied" do
@copied = @tasks.copy_for ProcessableAsset do
task :bar, :a => 4

0 comments on commit ce7e2e5

Please sign in to comment.