Class: RSpecRailsCaching::TestStore
- Inherits:
-
ActiveSupport::Cache::Store
- Object
- ActiveSupport::Cache::Store
- RSpecRailsCaching::TestStore
- Defined in:
- lib/rspec-rails-caching/test_store.rb
Instance Attribute Summary collapse
-
#cached ⇒ Object
readonly
Returns the value of attribute cached.
-
#cached_pages ⇒ Object
readonly
Returns the value of attribute cached_pages.
-
#context ⇒ Object
Returns the value of attribute context.
-
#data ⇒ Object
readonly
Returns the value of attribute data.
-
#expiration_patterns ⇒ Object
readonly
Returns the value of attribute expiration_patterns.
-
#expired ⇒ Object
readonly
Returns the value of attribute expired.
-
#expired_pages ⇒ Object
readonly
Returns the value of attribute expired_pages.
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #cached?(name) ⇒ Boolean
- #delete_entry(name, options = {}) ⇒ Object
- #delete_matched(matcher, options = {}) ⇒ Object
- #expired?(name) ⇒ Boolean
-
#initialize(options = nil) ⇒ TestStore
constructor
A new instance of TestStore.
- #page_cached?(options = {}) ⇒ Boolean
- #page_expired?(options = {}) ⇒ Boolean
- #read_entry(name, options = {}) ⇒ Object
- #reset ⇒ Object
- #write_entry(name, value, options = {}) ⇒ Object
Constructor Details
#initialize(options = nil) ⇒ TestStore
Returns a new instance of TestStore.
14 15 16 17 18 19 20 21 22 |
# File 'lib/rspec-rails-caching/test_store.rb', line 14 def initialize( = nil) @options = ? .dup : {do_read_cache: false} @data = {} @cached = [] @expired = [] @expiration_patterns = [] @cached_pages = [] @expired_pages = [] end |
Instance Attribute Details
#cached ⇒ Object (readonly)
Returns the value of attribute cached.
4 5 6 |
# File 'lib/rspec-rails-caching/test_store.rb', line 4 def cached @cached end |
#cached_pages ⇒ Object (readonly)
Returns the value of attribute cached_pages.
9 10 11 |
# File 'lib/rspec-rails-caching/test_store.rb', line 9 def cached_pages @cached_pages end |
#context ⇒ Object
Returns the value of attribute context.
12 13 14 |
# File 'lib/rspec-rails-caching/test_store.rb', line 12 def context @context end |
#data ⇒ Object (readonly)
Returns the value of attribute data.
7 8 9 |
# File 'lib/rspec-rails-caching/test_store.rb', line 7 def data @data end |
#expiration_patterns ⇒ Object (readonly)
Returns the value of attribute expiration_patterns.
6 7 8 |
# File 'lib/rspec-rails-caching/test_store.rb', line 6 def expiration_patterns @expiration_patterns end |
#expired ⇒ Object (readonly)
Returns the value of attribute expired.
5 6 7 |
# File 'lib/rspec-rails-caching/test_store.rb', line 5 def expired @expired end |
#expired_pages ⇒ Object (readonly)
Returns the value of attribute expired_pages.
10 11 12 |
# File 'lib/rspec-rails-caching/test_store.rb', line 10 def expired_pages @expired_pages end |
#options ⇒ Object
Returns the value of attribute options.
8 9 10 |
# File 'lib/rspec-rails-caching/test_store.rb', line 8 def @options end |
Instance Method Details
#cached?(name) ⇒ Boolean
50 51 52 |
# File 'lib/rspec-rails-caching/test_store.rb', line 50 def cached?(name) @cached.include?(name) end |
#delete_entry(name, options = {}) ⇒ Object
42 43 44 |
# File 'lib/rspec-rails-caching/test_store.rb', line 42 def delete_entry(name, = {}) @expired << name end |
#delete_matched(matcher, options = {}) ⇒ Object
46 47 48 |
# File 'lib/rspec-rails-caching/test_store.rb', line 46 def delete_matched(matcher, = {}) @expiration_patterns << matcher end |
#expired?(name) ⇒ Boolean
54 55 56 |
# File 'lib/rspec-rails-caching/test_store.rb', line 54 def expired?(name) @expired.include?(name) || @expiration_patterns.detect { |matcher| name =~ matcher } end |
#page_cached?(options = {}) ⇒ Boolean
58 59 60 |
# File 'lib/rspec-rails-caching/test_store.rb', line 58 def page_cached?( = {}) @cached_pages.include?(test_cache_url()) end |
#page_expired?(options = {}) ⇒ Boolean
62 63 64 |
# File 'lib/rspec-rails-caching/test_store.rb', line 62 def page_expired?( = {}) @expired_pages.include?(test_cache_url()) end |
#read_entry(name, options = {}) ⇒ Object
33 34 35 |
# File 'lib/rspec-rails-caching/test_store.rb', line 33 def read_entry(name, = {}) [:do_read_cache] ? @data[name] : nil end |
#reset ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/rspec-rails-caching/test_store.rb', line 24 def reset @data.clear @cached.clear @expired.clear @cached_pages.clear @expired_pages.clear @expiration_patterns.clear end |
#write_entry(name, value, options = {}) ⇒ Object
37 38 39 40 |
# File 'lib/rspec-rails-caching/test_store.rb', line 37 def write_entry(name, value, = {}) @data[name] = value if [:do_read_cache] @cached << name end |