Class: Excursion::Datastores::Test

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from Datastore

#all_apps, #app

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

#allObject



32
33
34
# File 'lib/excursion/datastores/test.rb', line 32

def all
  HashWithIndifferentAccess.new(@pool)
end

#application_classObject



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

def application_class
  Excursion::Pool::DummyApplication
end

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



27
28
29
# File 'lib/excursion/datastores/test.rb', line 27

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

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



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

def read(key)
  return @pool[key.to_sym] if key.to_s.match(/^_.*/) && @pool.has_key?(key.to_sym)

  return unless Excursion.configuration.test_providers.nil? || Excursion.configuration.test_providers.map(&:to_sym).include?(key.to_sym)
  @pool[key.to_sym] ||= application_class.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



22
23
24
# File 'lib/excursion/datastores/test.rb', line 22

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