Sha256: 44652caced69ab600f454e862eccc84c7428fd00f1c9d2900307c5666e8e50fe

Contents?: true

Size: 675 Bytes

Versions: 4

Compression:

Stored size: 675 Bytes

Contents

require 'valise/stack/decorator'
module Valise
  class Stack
    class ExtensionsDecorator < Decorator
      def initialize(stack)
        super
        @extensions = []
      end

      attr_accessor :extensions

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

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

      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
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
valise-1.1.3 lib/valise/stack/extensions-decorator.rb
valise-1.1.2 lib/valise/stack/extensions-decorator.rb
valise-1.1.1 lib/valise/stack/extensions-decorator.rb
valise-1.1.0 lib/valise/stack/extensions-decorator.rb