shawn42/gamebox — pull request #71 by jacius (2012-07-01 04:55:11+00:00)
Title: Make actors responsible for adding behavior to themselves

The rationale for this is that internal details of the actor (specifically its "this_object_context") are necessary to build a behavior to be used by the actor. So, I think it makes sense that the responsibility for this should rest with the Actor class. Plus, this makes the Actor API more logical and useful. Before, Actor#add_behavior was useless except as an implementation detail used by BehaviorFactory.

In practical terms, these commits shift all the work from the BehaviorFactory class into the Actor#add_behavior and Actor#build_behavior methods (build_behavior is a newly added method). As a result, the BehaviorFactory class is obsolete, but I have retained it for backward compatibility. BehaviorFactory#add_behavior now just calls Actor#add_behavior.

P.S. There are 3 pending Actor specs that I couldn't figure out how to make work, because of the unusual conjecting and mocking going on with actors in the specs.