Module: OpenWFE::ExpressionStorageBase
- Defined in:
- lib/openwfe/expool/expstorage.rb
Overview
This module contains the observe_expool method which binds the storage to the expression pool. It also features a to_s method for the expression storages including it.
Instance Method Summary collapse
-
#class_accepted?(fexp, include_classes, exclude_classes) ⇒ Boolean
Returns true if the given expression is in the list of included classes or false if it’s in the list of excluded classes…
-
#does_match?(options, fexp_or_fei) ⇒ Boolean
This method is used by the various implementations of find_expressions().
- #observe_expool ⇒ Object
-
#to_s ⇒ Object
a human readable representation of the content of the expression storage.
Instance Method Details
#class_accepted?(fexp, include_classes, exclude_classes) ⇒ Boolean
Returns true if the given expression is in the list of included classes or false if it’s in the list of excluded classes…
include_classes has precedence of exclude_classes.
158 159 160 161 162 163 164 165 166 167 168 |
# File 'lib/openwfe/expool/expstorage.rb', line 158 def class_accepted? (fexp, include_classes, exclude_classes) return false if include_classes and (not include_classes.find do |klazz| fexp.is_a?(klazz) end) return false if exclude_classes and exclude_classes.find do |klazz| fexp.is_a?(klazz) end true end |
#does_match?(options, fexp_or_fei) ⇒ Boolean
This method is used by the various implementations of find_expressions()
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# File 'lib/openwfe/expool/expstorage.rb', line 102 def does_match? (, fexp_or_fei) wfid = [:wfid] wfid_prefix = [:wfid_prefix] parent_wfid = [:parent_wfid] wfname = [:wfname] wfrevision = [:wfrevision] ic = [:include_classes] ec = [:exclude_classes] ic = Array(ic) if ic ec = Array(ec) if ec cs = [:consider_subprocesses] ap = [:applied] fexp, fei = if fexp_or_fei.is_a?(FlowExpressionId) [ nil, fexp_or_fei ] else [ fexp_or_fei, fexp_or_fei.fei ] end # # let's make it verbose... if fexp return false if (ap == true and not fexp.apply_time) return false if (ap == false and fexp.apply_time) return false unless class_accepted?(fexp, ic, ec) end return false \ if wfname and fei.wfname != wfname return false \ if wfrevision and fei.wfrevision != wfrevision return false \ if cs and fei.sub_instance_id != "" return false \ if wfid and fei.wfid != wfid return false \ if wfid_prefix and not fei.wfid.match("^#{wfid_prefix}") return false \ if parent_wfid and not fei.parent_wfid == parent_wfid true end |
#observe_expool ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/openwfe/expool/expstorage.rb', line 60 def observe_expool get_expression_pool.add_observer(:update) do |channel, fei, fe| ldebug { ":update for #{fei}" } self[fei] = fe end get_expression_pool.add_observer(:remove) do |channel, fei| ldebug { ":delete for #{fei}" } self.delete fei end end |
#to_s ⇒ Object
a human readable representation of the content of the expression storage.
Warning : this will display the content of the real storage, (especially when called against a cache).
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/openwfe/expool/expstorage.rb', line 79 def to_s s = "\n\n==== #{self.class} ====" find_expressions.each do |fexp| s << "\n" if fexp.kind_of?(RawExpression) s << "*raw" else s << " " end s << fexp.fei.to_s end s << "\n==== . ====\n" s end |