Class: OpenWFE::Extras::ActiveStoreParticipant

Inherits:
ActiveParticipant show all
Includes:
Enumerable
Defined in:
lib/openwfe/extras/participants/activeparticipants.rb

Overview

An extension of ActiveParticipant. It has a ‘store_name’ and it makes sure to flag every workitem it ‘consumes’ with that name (in its ‘store_name’ column/field).

This is the participant used mainly in ‘densha’ for human users.

Instance Method Summary collapse

Methods inherited from ActiveParticipant

#cancel, #reply_to_engine

Constructor Details

#initialize(store_name) ⇒ ActiveStoreParticipant

Returns a new instance of ActiveStoreParticipant.



524
525
526
527
528
# File 'lib/openwfe/extras/participants/activeparticipants.rb', line 524

def initialize (store_name)

    super()
    @store_name = store_name
end

Instance Method Details

#consume(workitem) ⇒ Object

This is the method called by the OpenWFEru engine to hand a workitem to this participant.



534
535
536
537
# File 'lib/openwfe/extras/participants/activeparticipants.rb', line 534

def consume (workitem)

    Workitem.from_owfe_workitem(workitem, @store_name)
end

#each(&block) ⇒ Object

Iterates over the workitems currently in this store.



542
543
544
545
546
547
548
549
550
551
# File 'lib/openwfe/extras/participants/activeparticipants.rb', line 542

def each (&block)

    return unless block

    wis = Workitem.find_by_store_name @store_name

    wis.each do |wi|
        block.call wi
    end
end