# File lib/state_machine/machine.rb, line 476
    def owner_class=(klass)
      @owner_class = klass
      
      # Create modules for extending the class with state/event-specific methods
      @helper_modules = helper_modules = {:instance => Module.new, :class => Module.new}
      owner_class.class_eval do
        extend helper_modules[:class]
        include helper_modules[:instance]
      end
      
      # Add class-/instance-level methods to the owner class for state initialization
      unless owner_class < StateMachine::InstanceMethods
        owner_class.class_eval do
          extend StateMachine::ClassMethods
          include StateMachine::InstanceMethods
        end
        
        define_state_initializer if @initialize_state
      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