Sha256: b33c2b950e9a3862713351b843d8a775303226f6ec8ca4619c60355ae9c699ad

Contents?: true

Size: 593 Bytes

Versions: 2

Compression:

Stored size: 593 Bytes

Contents

require 'config_builder/filter'

module ConfigBuilder
  class FilterStack

    def initialize
      @filter_stack = []
    end

    # @param input [Hash]
    #
    # @return [Hash]
    def filter(input)
      set_filters(input.delete(:filters))

      @filter_stack.inject(input) do |current_input, filter|
        filter.run(current_input)
      end
    end

    private

    def set_filters(list)
      if list.nil?
        @filter_stack << ConfigBuilder::Filter::Roles.new
      else
        raise NotImplementedError, "Custom lists of filters not implemented."
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
vagrant-config_builder-0.2.0 lib/config_builder/filter_stack.rb
vagrant-config_builder-0.1.0 lib/config_builder/filter_stack.rb