Sha256: f92d07de5de4243ea0d264a414c87d08090c19aaaaca75c308755093bbe59584

Contents?: true

Size: 615 Bytes

Versions: 16

Compression:

Stored size: 615 Bytes

Contents

module Determinator
  module Retrieve

    # An retriever that returns features that were previously stored
    # in the retriever. Useful for testing.
    class InMemoryRetriever
      def initialize
        @features = {}
      end

      # @param name [string,symbol] The name of the feature to retrieve
      def retrieve(name)
        @features.fetch(name.to_s, MissingResponse.new)
      end

      # @param feature [Determinator::Feature] The feature to store
      def store(feature)
        @features[feature.name] = feature
      end

      def clear!
        @features.clear
      end
    end

  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
determinator-2.9.3 lib/determinator/retrieve/in_memory_retriever.rb
determinator-2.9.2 lib/determinator/retrieve/in_memory_retriever.rb
determinator-2.9.1 lib/determinator/retrieve/in_memory_retriever.rb
determinator-2.9.0 lib/determinator/retrieve/in_memory_retriever.rb
determinator-2.8.0 lib/determinator/retrieve/in_memory_retriever.rb
determinator-2.7.1 lib/determinator/retrieve/in_memory_retriever.rb
determinator-2.7.0 lib/determinator/retrieve/in_memory_retriever.rb
determinator-2.6.0 lib/determinator/retrieve/in_memory_retriever.rb
determinator-2.5.4 lib/determinator/retrieve/in_memory_retriever.rb
determinator-2.5.3 lib/determinator/retrieve/in_memory_retriever.rb
determinator-2.5.2 lib/determinator/retrieve/in_memory_retriever.rb
determinator-2.5.1 lib/determinator/retrieve/in_memory_retriever.rb
determinator-2.5.0 lib/determinator/retrieve/in_memory_retriever.rb
determinator-2.4.4 lib/determinator/retrieve/in_memory_retriever.rb
determinator-2.4.3 lib/determinator/retrieve/in_memory_retriever.rb
determinator-2.4.2 lib/determinator/retrieve/in_memory_retriever.rb