Sha256: 6523597117e361fda0170e3b612b0ed95eb703426b8cd9d2ad17381db1e3afff

Contents?: true

Size: 657 Bytes

Versions: 3

Compression:

Stored size: 657 Bytes

Contents

module ContextExposer
  module Integrations
    class KeyFilter
      attr_reader :keys, :options

      def initialize keys, options = {}
        @keys = keys || []
        @options = options
      end

      # expose all exposures exposed by decent_exposure to context
      def filter
        the_keys = keys - except
        only.empty? ? the_keys : the_keys.select {|k| only.include? k.to_sym } 
      end

      def except
        @except ||= symbolize_opts :except
      end

      def only
        @only ||= symbolize_opts :only
      end

      def symbolize_opts name 
        (options[name.to_sym] || {}).map(&:to_sym)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
context_exposer-0.4.1 lib/context_exposer/integrations/key_filter.rb
context_exposer-0.4.0 lib/context_exposer/integrations/key_filter.rb
context_exposer-0.3.0 lib/context_exposer/integrations/key_filter.rb