Class: Valise::Stack::PrefixesDecorator
- Inherits:
-
Decorator
- Object
- Valise::Stack
- Decorator
- Valise::Stack::PrefixesDecorator
- Defined in:
- lib/valise/stack/prefixes-decorator.rb
Instance Attribute Summary collapse
-
#prefixes ⇒ Object
Returns the value of attribute prefixes.
Attributes inherited from Valise::Stack
Instance Method Summary collapse
- #decorate_item(item) ⇒ Object
-
#initialize(stack) ⇒ PrefixesDecorator
constructor
A new instance of PrefixesDecorator.
- #inspect ⇒ Object
- #reget(root) ⇒ Object
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
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) ⇒ PrefixesDecorator
Returns a new instance of PrefixesDecorator.
5 6 7 8 |
# File 'lib/valise/stack/prefixes-decorator.rb', line 5 def initialize(stack) super @prefixes = [] end |
Instance Attribute Details
#prefixes ⇒ Object
Returns the value of attribute prefixes.
10 11 12 |
# File 'lib/valise/stack/prefixes-decorator.rb', line 10 def prefixes @prefixes end |
Instance Method Details
#decorate_item(item) ⇒ Object
22 23 24 25 26 27 28 |
# File 'lib/valise/stack/prefixes-decorator.rb', line 22 def decorate_item(item) dir, file = *item.segments.split @prefixes.each do |pfx| dec_stack = @stacks[dir + (pfx + file.to_s)] yield(dec_stack.item_for(item.root)) end end |
#inspect ⇒ Object
12 13 14 |
# File 'lib/valise/stack/prefixes-decorator.rb', line 12 def inspect "P#{prefixes.inspect}x#{@stack.inspect}" end |
#reget(root) ⇒ Object
16 17 18 19 20 |
# File 'lib/valise/stack/prefixes-decorator.rb', line 16 def reget(root) decorated = self.new(super) decorated.prefixes = self.prefixes decorated end |