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
37 38 39 |
# File 'lib/excursion/datastores/test.rb', line 37 def all HashWithIndifferentAccess.new(@pool) end |
#all_apps ⇒ Object
14 15 16 17 18 19 |
# File 'lib/excursion/datastores/test.rb', line 14 def all_apps app_hash = HashWithIndifferentAccess.new all.each do |k,v| app_hash[k.to_sym] = Excursion::Pool::DummyApplication.from_cache(v) end 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
32 33 34 |
# File 'lib/excursion/datastores/test.rb', line 32 def delete(key) @pool.delete(key.to_sym) end |
#read(key) ⇒ Object Also known as: get
21 22 23 24 |
# File 'lib/excursion/datastores/test.rb', line 21 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
27 28 29 |
# File 'lib/excursion/datastores/test.rb', line 27 def write(key, value) @pool[key.to_sym] = value end |