Jay Fields Thoughts: Ruby: State pattern using Modules and Facets:

"each method is protected so they must be accessed via the delegations, and an error will occur if they are accessed directly" You got me here. Till now I used to think that Ruby copies all the definition of a module into the definition of the class that includes it. Going by that logic, I couldn't explain your program's behavior as name method would be redefined and the modules' methods would be lost... I consulted "Programming Ruby": If a module is included within a class definition, the module's constants, class variables, and instance methods are effectively bundled into an anonymous (and inaccessible) superclass for that class. In particular, objects of the class will respond to messages sent to the module's instance methods. Your program made better sense now. The original definitions were not lost as they reside in a superclass (anonymous one). However this brought ...