Method: Alki::Execution::OverlayMap#index

Defined in:
lib/alki/execution/overlay_map.rb

#index(key, tags) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/alki/execution/overlay_map.rb', line 8

def index(key,tags)
  self.class.new.tap do |new_overlays|
    @overlays.each do |target,overlays|
      target = target.dup
      if target.size == 1 && target[0].to_s.start_with?('%')
        if tags
          tag = target[0].to_s[1..-1].to_sym
          tags.elements_in(tag).each do |path|
            new_overlays.add path, *overlays
          end
        end
      elsif target.empty? || target.shift == key.to_sym
        new_overlays.add target, *overlays
      end
    end
  end
end