<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -78,7 +78,7 @@ module RedSteak
 
     def inspect
       @inspect ||=
-        &quot;#&lt;#{self.class} #{@message.inspect}#{@options.keys.sort { |a, b| a.to_s &lt;=&gt; b.to_s }.map { | k | &quot; #{k.inspect} =&gt; #{@options[k].inspect}&quot; }.join('')}&gt;&quot;.freeze
+        &quot;#&lt;#{self.class} #{@message.inspect}#{@options.keys.sort { |a, b| a.to_s &lt;=&gt; b.to_s }.map { | k | &quot;\n  #{k.inspect} =&gt; #{@options[k].inspect}&quot; }.join('')}&gt;&quot;.freeze
     end
 
 </diff>
      <filename>lib/red_steak/error.rb</filename>
    </modified>
    <modified>
      <diff>@@ -309,16 +309,16 @@ module RedSteak
         unless t.empty?
           case t.size
           when 0
-            _raise UnhandledEvent, &quot;No transitions for event&quot;,
+            _raise Error::UnhandledEvent, &quot;No transitions for event&quot;,
               :event =&gt; @event
           when 1
             event_args = event.size &gt; 1 ? @event[1 .. -1] : EMPTY_ARRAY
             transition_fired, @trigger = *t.first
             queue_transition! transition_fired, event_args
           else
-            _raise UnhandledEvent, &quot;Too many transititons for event&quot;,
+            _raise Error::UnhandledEvent, &quot;Too many transititons for event&quot;,
               :event =&gt; @event,
-              :transitions =&gt; t
+              :transitions =&gt; t # .map { | x | [ x[0].to_uml_s, x[1] ] }
            end
         end
 
@@ -727,14 +727,15 @@ module RedSteak
 
     def _log msg = nil
       return unless @logger
-      msg ||= yield
       case 
       when Proc === @logger
+        msg ||= yield
         @logger.call(msg)
       when ::IO === @logger
+        msg ||= yield
         @logger.puts &quot;#{self.to_s} #{state.to_s} #{msg}&quot;
       when defined?(::Log4r) &amp;&amp; (Log4r::Logger === @logger)
-        @logger.send(log_level || :debug, msg)
+        @logger.send(log_level || :debug) { msg ||= yield }
       end
     end
 
@@ -878,14 +879,14 @@ module RedSteak
     def fire_transition! trans, args
       _log { &quot;fire_transition! #{trans.inspect}&quot; }
 
-      _raise RedSteak::Error::UnexpectedRecursion, :transition if @transition
+      _raise Error::UnexpectedRecursion, :transition if @transition
 
       old_state = @state
 
       @transition = trans
 
       # Behavior: Transition effect.
-      _raise RedSteak::Error::UnexpectedRecursion, :effect if @in_effect
+      _raise Error::UnexpectedRecursion, :effect if @in_effect
       @in_effect = true
       _log { &quot;effect! #{trans.inspect}&quot; }
       trans.effect!(self, args)</diff>
      <filename>lib/red_steak/machine.rb</filename>
    </modified>
    <modified>
      <diff>@@ -63,9 +63,22 @@ module RedSteak
         end
 
         if force_send
-          # $stderr.puts &quot;  _behavior! #{self.inspect} #{action.inspect} #{machine.inspect}\n    =&gt; #{c}.send(#{behavior.inspect}, #{machine}, #{self.inspect}, *#{args.inspect})&quot;
-
-          return c.send(behavior, machine, self, *args)
+          meth_arity = c.method(behavior).arity rescue args.size + 2
+          case 
+          when meth_arity == 0
+            args = EMPTY_ARRAY
+          when meth_arity &lt; 0
+            args = args.dup # args might be frozen.
+            args.unshift self
+            args.unshift machine
+          else
+            args = args.dup # args might be frozen.
+            args.unshift self
+            args.unshift machine
+            args = [0 ... meth_arity]
+          end
+          # $stderr.puts &quot;  _behavior! #{self.inspect} #{action.inspect} #{machine.inspect}\n    =&gt; #{c}.send(#{behavior.inspect}, *#{args.inspect})&quot;
+          return c.send(behavior, *args)
         end
       end
       default_value</diff>
      <filename>lib/red_steak/named_element.rb</filename>
    </modified>
    <modified>
      <diff>@@ -43,7 +43,7 @@ describe 'RedSteak::Error' do
     e.options[:message].should == nil
     e.options[:foo].should == :bar
     e.message.should == &quot;message&quot;
-    e.inspect.should == &quot;#&lt;RedSteak::Error \&quot;message\&quot; :foo =&gt; :bar&gt;&quot; 
+    e.inspect.should == &quot;#&lt;RedSteak::Error \&quot;message\&quot;\n  :foo =&gt; :bar&gt;&quot; 
   end
 
 </diff>
      <filename>test/error.spec</filename>
    </modified>
    <modified>
      <diff>@@ -26,6 +26,10 @@ describe 'RedSteak::Machine#event!' do
       @number = &quot;&quot;
     end
 
+    ########################################
+    # dialed digit management.
+    #
+
     def prefix number = self.number
       case number
       when /^0/
@@ -45,24 +49,47 @@ describe 'RedSteak::Machine#event!' do
       prefix.first
     end
 
-    def valid *args
+    def valid 
       p = prefix number
       p[0] != nil &amp;&amp; p[1] == number.size
     end 
 
-    def incomplete *args
+    def incomplete 
       ! valid &amp;&amp; ! invalid
     end
 
-    def invalid *args
+    def invalid 
       ! (number =~ /^\d+$/)
     end
 
+
+    ########################################
+    # Methods that generate events.
+    #
+
     def dial_digit n
       @number &lt;&lt; n
       @m.event! [ :dial_digit, n ]
     end
 
+    [
+     :after_timeout,
+     :lift_reciever,
+     :connected,
+     :busy,
+     :callee_answers,
+     :callee_hangs_up,
+     :caller_hangs_up,
+     :terminate,
+    ].each do | meth |
+      class_eval &lt;&lt;&quot;RUBY&quot;, __FILE__, __LINE__
+def #{meth}
+  $stderr.puts &quot;#{name} #{meth}()&quot;
+  @m.event! [ #{meth.inspect} ]
+end
+RUBY
+    end
+
 
     def inspect
       &quot;#{self.class} #{name} n=#{number.inspect} t=#{call_type.inspect} state=#{@m.state.to_s}&quot;
@@ -109,9 +136,6 @@ describe 'RedSteak::Machine#event!' do
                 :guard =&gt; :incomplete
               transition :time_out,
                 :trigger =&gt; :after_timeout
-              transition :dialing,
-                :trigger =&gt; :dial_digit,
-                :guard =&gt; :incomplete
               transition :connecting,
                 :trigger =&gt; :dial_digit,
                 :guard =&gt; :valid,
@@ -192,6 +216,7 @@ describe 'RedSteak::Machine#event!' do
   attr_accessor :t
 
   it 'transitions using transition_if_valid!' do
+  begin
     self.t = Telephone.new
     t.name = &quot;t&quot;
     sm = t.sm
@@ -229,11 +254,15 @@ describe 'RedSteak::Machine#event!' do
       when Array
         t.send(*event)
       else
-        m.event! event
+        t.send(event)
       end
       m.run_events!
       render_graph(m)
     end
+  rescue Exception =&gt; err
+    $stderr.puts &quot;UNEXPECTED ERROR: #{err.inspect}&quot;
+    raise err
+  end
   end
 
 end # describe</diff>
      <filename>test/event.spec</filename>
    </modified>
    <modified>
      <diff>@@ -423,7 +423,7 @@ describe RedSteak do
       err[:transitions].should == nil
       err[:state].should == m.state
       err.state.should == m.state
-      err.inspect.should == &quot;#&lt;RedSteak::Error::UnknownTransition \&quot;transition_to_next_state!\&quot; :machine =&gt; #&lt;RedSteak::Machine :test [:end]&gt; :state =&gt; #&lt;RedSteak::State test end&gt;&gt;&quot;
+      err.inspect.should == &quot;#&lt;RedSteak::Error::UnknownTransition \&quot;transition_to_next_state!\&quot;\n  :machine =&gt; #&lt;RedSteak::Machine :test [:end]&gt;\n  :state =&gt; #&lt;RedSteak::State test end&gt;&gt;&quot;
     end
 
     m.history.map { |h| h[:previous_state].to_s }.should ==</diff>
      <filename>test/red_steak.spec</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>7afd4bcf0503d97e3dea852a59e0fd541bcfa386</id>
    </parent>
  </parents>
  <author>
    <name>Kurt Stephens</name>
    <login>kstephens</login>
    <email>ks.github@kurtstephens.com</email>
  </author>
  <url>http://github.com/kstephens/red_steak/commit/229df7a1d32c54c8cfde0fc26d0c80ece5a931dc</url>
  <id>229df7a1d32c54c8cfde0fc26d0c80ece5a931dc</id>
  <committed-date>2009-05-08T13:54:10-07:00</committed-date>
  <authored-date>2009-05-08T13:54:10-07:00</authored-date>
  <message>Error#inspect now has newlines to aid human comprehension.
Preliminary support for improved #_behavior! callback argument handling.</message>
  <tree>69e6b11942ee74912ce3931e1af43eb983338989</tree>
  <committer>
    <name>Kurt Stephens</name>
    <login>kstephens</login>
    <email>ks.github@kurtstephens.com</email>
  </committer>
</commit>
