# File lib/ruote/exp/ro_filters.rb, line 96
    def  lookup_filterlookup_filter(workitem)

      f = attribute(:filter)

      if f.nil? and workitem

        reply = if t = attribute(:take)
          Array(t).collect { |tt| { 'field' => tt, 'take' => true } }
        elsif d = attribute(:discard)
          if d == true
            [ { 'field' => /.+/, 'discard' => 'all' } ]
          else
            Array(d).collect { |dd| { 'field' => dd, 'discard' => true } }
          end
        else
          nil
        end

        f = { 'reply' => reply } if reply
      end

      return nil unless f
        # no filter

      if f.is_a?(Hash)
        f['in'] = [] unless f['in'] or f['apply']
        f['out'] = [] unless f['out'] or f['reply']
      end
        # empty ins and outs for a sucessful narrowing

      3.times { f = narrow_filter(f, workitem) }

      f or raise ArgumentError.new("found no filter corresponding to '#{f}'")
    end