Class: Excursion::Datastores::Test
- Defined in:
- lib/excursion/datastores/test.rb
Instance Attribute Summary collapse
-
#pool ⇒ Object
Returns the value of attribute pool.
Instance Method Summary collapse
- #all ⇒ Object
- #all_apps ⇒ Object
- #app(key) ⇒ Object
- #delete(key) ⇒ Object (also: #unset)
- #read(key) ⇒ Object (also: #get)
- #write(key, value) ⇒ Object (also: #set)
Instance Attribute Details
#pool ⇒ Object
Returns the value of attribute pool.
8 9 10 |
# File 'lib/excursion/datastores/test.rb', line 8 def pool @pool end |
Instance Method Details
#all ⇒ Object
38 39 40 |
# File 'lib/excursion/datastores/test.rb', line 38 def all HashWithIndifferentAccess.new(@pool) end |
#all_apps ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/excursion/datastores/test.rb', line 14 def all_apps apps = [] all.values.each do |v| apps << Excursion::Pool::DummyApplication.from_cache(v) end apps end |
#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
33 34 35 |
# File 'lib/excursion/datastores/test.rb', line 33 def delete(key) @pool.delete(key.to_sym) end |
#read(key) ⇒ Object Also known as: get
22 23 24 25 |
# File 'lib/excursion/datastores/test.rb', line 22 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
28 29 30 |
# File 'lib/excursion/datastores/test.rb', line 28 def write(key, value) @pool[key.to_sym] = value end |