# File lib/state_machine/machine.rb, line 455
    def owner_class=(klass)
      @owner_class = klass
      
      # Create modules for extending the class with state/event-specific methods
      class_helper_module = @class_helper_module = Module.new
      instance_helper_module = @instance_helper_module = Module.new
      owner_class.class_eval do
        extend class_helper_module
        include instance_helper_module
      end
      
      # Add class-/instance-level methods to the owner class for state initialization
      unless owner_class.included_modules.include?(StateMachine::InstanceMethods)
        owner_class.class_eval do
          extend StateMachine::ClassMethods
          include StateMachine::InstanceMethods
        end
        
        define_state_initializer
      end
      
      # Record this machine as matched to the name in the current owner class.
      # This will override any machines mapped to the same name in any superclasses.
      owner_class.state_machines[name] = self
    end