Module: OpenWFE::FilterMixin

Included in:
FilterExpression, ParticipantExpression
Defined in:
lib/openwfe/expressions/filter.rb

Overview

This mixin adds filtering capabilities to a FlowExpression.

It’s used by the ‘participant’ and ‘filter’ expressions.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#filterObject

Returns the value of attribute filter.



54
55
56
# File 'lib/openwfe/expressions/filter.rb', line 54

def filter
  @filter
end

Instance Method Details

#filter_in(workitem, filter_attribute_name = :filter) ⇒ Object

Used when the workitem enters the ‘filtered zone’. Will replace the attributes of the workitem with filtered ones. Assumes the original workitem is kept under @applied_workitem.



61
62
63
64
65
66
67
68
69
# File 'lib/openwfe/expressions/filter.rb', line 61

def filter_in workitem, filter_attribute_name=:filter

    @filter = get_filter filter_attribute_name, workitem

    return unless @filter

    workitem.attributes = @filter.filter_in workitem.attributes
    workitem.filter = @filter.dup
end

#filter_out(incoming_workitem) ⇒ Object

Prepares the workitem for leaving the ‘filtered zone’. Makes sure hidden and unwritable fields haven’t been tampered with. Enforces the ‘add_ok’, ‘remove_ok’, ‘closed’ filter directives. Assumes the original workitem is kept under @applied_workitem.



77
78
79
80
81
82
83
84
85
# File 'lib/openwfe/expressions/filter.rb', line 77

def filter_out incoming_workitem

    return unless @filter

    incoming_workitem.filter = nil

    incoming_workitem.attributes = @filter.filter_out(
        @applied_workitem.attributes, incoming_workitem.attributes)
end