diff --git a/lib/cached_resource/cached_resource.rb b/lib/cached_resource/cached_resource.rb index 82ecfd4..22c7bee 100644 --- a/lib/cached_resource/cached_resource.rb +++ b/lib/cached_resource/cached_resource.rb @@ -19,17 +19,17 @@ def cached_resource(options={}) def setup_cached_resource!(options) @cached_resource = CachedResource::Configuration.new(options) # puts "OK WE ARE SET UP!" - if @cached_resource.concurrent_write - @cached_resource.require_concurrent_ruby - # begin - # send :require, 'concurrent/promise' - # rescue LoadError - # @cached_resource.logger.error( - # "`concurrent_write` option is enabled, but `concurrent-ruby` is not an installed dependency" - # ) - # raise - # end - end + # if @cached_resource.concurrent_write + # @cached_resource.require_concurrent_ruby + # # begin + # # send :require, 'concurrent/promise' + # # rescue LoadError + # # @cached_resource.logger.error( + # # "`concurrent_write` option is enabled, but `concurrent-ruby` is not an installed dependency" + # # ) + # # raise + # # end + # end send :include, CachedResource::Caching @cached_resource end diff --git a/lib/cached_resource/configuration.rb b/lib/cached_resource/configuration.rb index ea532c6..82a0d78 100644 --- a/lib/cached_resource/configuration.rb +++ b/lib/cached_resource/configuration.rb @@ -47,7 +47,8 @@ def initialize(options={}) # Set our concurrent_write. Can't override OpenStruct setters # in a straightforward way. - @concurrent_write = data.delete :concurrent_write + # @concurrent_write = data.delete :concurrent_write + self.concurrent_write = data.delete :concurrent_write super(data) end @@ -68,10 +69,11 @@ def off! self.enabled = false end + # Toggle writing to cache in a thread. Requires + # concurrent/promise if enabled. def concurrent_write=(value) require_concurrent_ruby if value @concurrent_write = value - puts "WE REQUIRED ID!\n", value end # require concurrent/promise, throwing an exception if necessary