Class: Array

Inherits:
Object show all
Defined in:
lib/event.rb

Instance Method Summary collapse

Instance Method Details

#mpt_filterchain_reorganizeObject



3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/event.rb', line 3

def mpt_filterchain_reorganize
  index = 0
  while index < self.size
    filter = self[index]
    filter_opts = filter[:options]
    unless filter_opts[:after].nil?
      (self.size-1).downto(index) do |i|
        fo = self[i][:options]
        unless fo[:as].nil?
          if fo[:as] == filter_opts[:after]
            new_chain = []
            new_chain += self[0..index-1] if index > 0
            new_chain += [self[i]]
            new_chain += self[index..i-1]
            new_chain += self[i+1..self.size-1]
            self.replace new_chain 
            index = 0
            break
          end # if :as matched with :after
        end	# unless :as is nil				
      end # for next items
    end # unless :after is nil
    index += 1
  end # while index < list size
end