Sha256: 8408a55534c705bac3af6a894eeeb7485eeb7daf2a1f34cef20f7a607b50cf72

Contents?: true

Size: 996 Bytes

Versions: 9

Compression:

Stored size: 996 Bytes

Contents

require 'pallets'

class DoGroceries < Pallets::Workflow
  task 'EnterShop'
  task 'GetShoppingCart' => 'EnterShop'
  task 'PutMilk' => 'GetShoppingCart'
  task 'PutBread' => 'GetShoppingCart'
  task 'Pay' => ['PutMilk', 'PutBread']
  task 'GoHome' => 'Pay'
end

class EnterShop < Pallets::Task
  def run
    puts "Entering #{context['shop_name']}"
  end
end

class GetShoppingCart < Pallets::Task
  def run
    puts "Where's that 50 cent coin??"
    context['need_to_return_coin'] = true
  end
end

class PutMilk < Pallets::Task
  def run
    puts "Whole or half? Hmm..."
    sleep 1
  end
end

class PutBread < Pallets::Task
  def run
    puts "Got the bread"
  end
end

class Pay < Pallets::Task
  def run
    puts "Paying by #{context['pay_by']}"
    sleep 2
  end
end

class GoHome < Pallets::Task
  def run
    puts "Done!!"

    if context['need_to_return_coin']
      puts '...forgot to get my coin back...'
    end
  end
end

DoGroceries.new(shop_name: 'Pallet Shop', pay_by: :card).run

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
pallets-0.11.0 examples/do_groceries.rb
pallets-0.10.0 examples/do_groceries.rb
pallets-0.9.0 examples/do_groceries.rb
pallets-0.8.0 examples/do_groceries.rb
pallets-0.7.0 examples/do_groceries.rb
pallets-0.6.0 examples/do_groceries.rb
pallets-0.5.1 examples/do_groceries.rb
pallets-0.5.0 examples/do_groceries.rb
pallets-0.4.0 examples/do_groceries.rb