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.



677
678
679
680
681
# File 'lib/openwfe/extras/participants/activeparticipants.rb', line 677

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.



687
688
689
690
691
692
693
694
# File 'lib/openwfe/extras/participants/activeparticipants.rb', line 687

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.



699
700
701
702
703
704
705
706
707
708
# File 'lib/openwfe/extras/participants/activeparticipants.rb', line 699

def each (&block)

    return unless block

    wis = Workitem.find_by_store_name @store_name

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