Class: Excursion::Datastores::Test

Inherits:
Datastore
  • Object
show all
Defined in:
lib/excursion/datastores/test.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#poolObject

Returns the value of attribute pool.



8
9
10
# File 'lib/excursion/datastores/test.rb', line 8

def pool
  @pool
end

Instance Method Details

#app(key) ⇒ Object



10
11
12
# File 'lib/excursion/datastores/test.rb', line 10

def app(key)
  Excursion::Pool::DummyApplication.from_cache(read(key))
end

#delete(key) ⇒ Object Also known as: unset



25
26
27
# File 'lib/excursion/datastores/test.rb', line 25

def delete(key)
  @pool.delete(key.to_sym)
end

#read(key) ⇒ Object Also known as: get



14
15
16
17
# File 'lib/excursion/datastores/test.rb', line 14

def read(key)
  return unless Excursion.configuration.test_providers.nil? || Excursion.configuration.test_providers.map(&:to_sym).include?(key.to_sym)
  @pool[key.to_sym] ||= Excursion::Pool::DummyApplication.new(key, {default_url_options: {host: 'www.example.com'}}, ActionDispatch::Routing::RouteSet::NamedRouteCollection.new).to_cache
end

#write(key, value) ⇒ Object Also known as: set



20
21
22
# File 'lib/excursion/datastores/test.rb', line 20

def write(key, value)
  @pool[key.to_sym] = value
end