Class: SocialAvatarProxy::Configuration::Cache
- Inherits:
-
Object
- Object
- SocialAvatarProxy::Configuration::Cache
- Defined in:
- lib/social_avatar_proxy/configuration/cache.rb
Instance Method Summary collapse
- #configure(&block) ⇒ Object
- #disabled? ⇒ Boolean
- #enabled? ⇒ Boolean
- #fetch(options = {}, &block) ⇒ Object
- #read(options = {}) ⇒ Object
- #write(file, options = {}) ⇒ Object
Instance Method Details
#configure(&block) ⇒ Object
26 27 28 29 |
# File 'lib/social_avatar_proxy/configuration/cache.rb', line 26 def configure(&block) enable instance_eval(&block) end |
#disabled? ⇒ Boolean
31 32 33 |
# File 'lib/social_avatar_proxy/configuration/cache.rb', line 31 def disabled? !enabled? end |
#enabled? ⇒ Boolean
35 36 37 |
# File 'lib/social_avatar_proxy/configuration/cache.rb', line 35 def enabled? !!@enabled end |
#fetch(options = {}, &block) ⇒ Object
12 13 14 15 16 17 18 19 20 21 22 23 24 |
# File 'lib/social_avatar_proxy/configuration/cache.rb', line 12 def fetch( = {}, &block) # if the cache is enabled attempt read file = attempt_read() # if read fails yield the block # if the cache is enabled attempt write # return the block result unless file file = block.yield attempt_write(file, ) if file end # return the file file end |
#read(options = {}) ⇒ Object
4 5 6 |
# File 'lib/social_avatar_proxy/configuration/cache.rb', line 4 def read( = {}) false end |
#write(file, options = {}) ⇒ Object
8 9 10 |
# File 'lib/social_avatar_proxy/configuration/cache.rb', line 8 def write(file, = {}) file end |