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 Attribute Summary

Attributes inherited from ActiveParticipant

#compact_workitems

Instance Method Summary collapse

Methods inherited from ActiveParticipant

#cancel, #reply_to_engine

Constructor Details

#initialize(store_name) ⇒ ActiveStoreParticipant

Returns a new instance of ActiveStoreParticipant.



703
704
705
706
707
# File 'lib/openwfe/extras/participants/activeparticipants.rb', line 703

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.



713
714
715
716
717
718
719
720
# File 'lib/openwfe/extras/participants/activeparticipants.rb', line 713

def consume (workitem)

    if compact_workitems
        workitem.attributes["compact_workitems"] = true
    end

    Workitem.from_owfe_workitem(workitem, @store_name)
end

#each(&block) ⇒ Object

Iterates over the workitems currently in this store.



725
726
727
728
729
730
731
732
733
734
# File 'lib/openwfe/extras/participants/activeparticipants.rb', line 725

def each (&block)

    return unless block

    wis = Workitem.find_by_store_name @store_name

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