Class: Valise::Stack::ExtensionsDecorator

Inherits:
Decorator show all
Defined in:
lib/valise/stack/extensions-decorator.rb

Instance Attribute Summary collapse

Attributes inherited from Valise::Stack

#segments, #valise

Instance Method Summary collapse

Methods inherited from Decorator

#diffed, #each, #merged, #rel_path, #valise

Methods inherited from Valise::Stack

#below, #depth_of, #diffed, #dump_load, #each, #exts, #find, #item_for, #merge_diff, #merged, #not_above, #pfxs, #raw_find, #rel_path, #reverse

Methods included from ItemEnum

#absent, #present, #writable

Methods included from Unpath

#clean_pathname, #containing_workspace, #current_directory, #file_from_backtrace, #from_here, #make_pathname, #starting_directory, #up_to, #up_until

Constructor Details

#initialize(stack) ⇒ ExtensionsDecorator

Returns a new instance of ExtensionsDecorator.



5
6
7
8
# File 'lib/valise/stack/extensions-decorator.rb', line 5

def initialize(stack)
  super
  @extensions = []
end

Instance Attribute Details

#extensionsObject

Returns the value of attribute extensions.



10
11
12
# File 'lib/valise/stack/extensions-decorator.rb', line 10

def extensions
  @extensions
end

Instance Method Details

#decorate_item(item) ⇒ Object



22
23
24
25
26
27
28
# File 'lib/valise/stack/extensions-decorator.rb', line 22

def decorate_item(item)
  dir, file = *item.segments.split
  @extensions.each do |ext|
    ext_stack = @stacks[dir + (file.to_s + ext)]
    yield(ext_stack.item_for(item.root))
  end
end

#inspectObject



12
13
14
# File 'lib/valise/stack/extensions-decorator.rb', line 12

def inspect
  @stack.inspect + "xS#{extensions.inspect}"
end

#reget(root) ⇒ Object



16
17
18
19
20
# File 'lib/valise/stack/extensions-decorator.rb', line 16

def reget(root)
  decorated = self.new(super)
  decorated.extensions = self.extensions
  decorated
end