On Wed, Apr 20, 2011 at 08:44:48PM +0900, John Mettraux wrote:
> 
> On Wed, Apr 20, 2011 at 12:18:18PM +0200, Simone Carletti wrote:
> > 
> > At first glance, I thought that was the case, at least before I realized
> > #update is just an alias for #consume. It means, if you customize the
> > #consume logic, you are actually overriding the #update as well.

Hello again,

are you sure of that ?

---8<---
class A
  def consume(wi)
    p [ :consume, wi ]
  end
  alias update consume
end

class B < A
  def consume(wi)
    p [ :b_consume, wi ]
  end
end

a = A.new
a.consume(:x)
a.update(:x)

b = B.new
b.consume(:y)
b.update(:y)
--->8---

(initially I did

---8<---
  class MyParticipant < Ruote::StorageParticipant
    def consume(wi)
      @context.tracer << "consume\n"
      super
    end
    #def update(wi)
    #  @context.tracer << "update\n"
    #  super
    #end
  end

  def test_override_update

    pdef = Ruote.define do
      alpha
    end

    @engine.register do
      alpha MyParticipant
    end

    @engine.launch(pdef)
    @engine.wait_for(:alpha)

    part = @engine.participant(:alpha)

    part.update(part.first)

    assert_equal %w[ consume ], @tracer.to_a
  end
--->8---

)


Best regards,

-- 
John Mettraux - http://jmettraux.wordpress.com

-- 
you received this message because you are subscribed to the "ruote users" group.
to post : send email to [email protected]
to unsubscribe : send email to [email protected]
more options : http://groups.google.com/group/openwferu-users?hl=en

Reply via email to