class Excursion::Datastores::Test

Attributes

pool[RW]

Public Class Methods

new(pool=nil) click to toggle source
# File lib/excursion/datastores/test.rb, line 38
def initialize(pool=nil)
  @pool = {}
  @pool = pool.dup unless pool.nil?
end

Public Instance Methods

all() click to toggle source
# File lib/excursion/datastores/test.rb, line 32
def all
  HashWithIndifferentAccess.new(@pool)
end
application_class() click to toggle source
# File lib/excursion/datastores/test.rb, line 10
def application_class
  Excursion::Pool::DummyApplication
end
delete(key) click to toggle source
# File lib/excursion/datastores/test.rb, line 27
def delete(key)
  @pool.delete(key.to_sym)
end
Also aliased as: unset
get(key)
Alias for: read
read(key) click to toggle source
# File lib/excursion/datastores/test.rb, line 14
def read(key)
  return @pool[key.to_sym] if option_key?(key)

  return unless test_provider?(key)
  @pool[key.to_sym] ||= application_class.new(key, default_options, ActionDispatch::Routing::RouteSet::NamedRouteCollection.new).to_cache
end
Also aliased as: get
set(key, value)
Alias for: write
unset(key)
Alias for: delete
write(key, value) click to toggle source
# File lib/excursion/datastores/test.rb, line 22
def write(key, value)
  @pool[key.to_sym] = value
end
Also aliased as: set

Protected Instance Methods

default_options() click to toggle source
# File lib/excursion/datastores/test.rb, line 47
def default_options
  {default_url_options: {host: 'www.example.com'}}
end
option_key?(key) click to toggle source
# File lib/excursion/datastores/test.rb, line 51
def option_key?(key)
  key.to_s.match(/^_.*/) && @pool.has_key?(key.to_sym)
end
test_provider?(key) click to toggle source
# File lib/excursion/datastores/test.rb, line 43
def test_provider?(key)
  Excursion.configuration.test_providers.nil? || Excursion.configuration.test_providers.map(&:to_sym).include?(key.to_sym)
end