Class: Determinator::Retrieve::InMemoryRetriever

Inherits:
Object
  • Object
show all
Defined in:
lib/determinator/retrieve/in_memory_retriever.rb

Overview

An retriever that returns features that were previously stored in the retriever. Useful for testing.

Instance Method Summary collapse

Constructor Details

#initializeInMemoryRetriever

Returns a new instance of InMemoryRetriever.



7
8
9
# File 'lib/determinator/retrieve/in_memory_retriever.rb', line 7

def initialize
  @features = {}
end

Instance Method Details

#clear!Object



21
22
23
# File 'lib/determinator/retrieve/in_memory_retriever.rb', line 21

def clear!
  @features.clear
end

#retrieve(name) ⇒ Object

Parameters:

  • name (string, symbol)

    The name of the feature to retrieve



12
13
14
# File 'lib/determinator/retrieve/in_memory_retriever.rb', line 12

def retrieve(name)
  @features.fetch(name.to_s, MissingResponse.new)
end

#store(feature) ⇒ Object

Parameters:



17
18
19
# File 'lib/determinator/retrieve/in_memory_retriever.rb', line 17

def store(feature)
  @features[feature.name] = feature
end