Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save antonymarcano/877467 to your computer and use it in GitHub Desktop.
Save antonymarcano/877467 to your computer and use it in GitHub Desktop.
$:.unshift(File.dirname(__FILE__), ".")
require 'rubygems'
require 'rspec'
module Butler
def put_fork_on_the_left_of place
place.unshift "fork"
place
end
def put_knife_on_the_right_of place
place.push "knife"
place
end
end
module LayTable
def follow_instructions
place = []
put_fork_on_the_left_of place
put_knife_on_the_right_of place
end
end
class MyActor
#decide how we will make the actor know in which role they should perform the task
def initialize role
extend role
end
def perform task
recall_how_to_do task
follow_instructions
end
private
def recall_how_to_do something
extend something
end
end
describe "Something" do
it "Something" do
butler = MyActor.new Butler
butler.perform(LayTable).should == ["fork","knife"]
end
end
@antonymarcano
Copy link
Author

This approach removes the need for too much knowledge of what's being operated on.
If some value needs to be remembered for later use we should ask the actor to take_note_of key,value to save any information that will later need to be recalled... It can then be explicitly recalled by subsequent tasks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment