Module: WarmingDrawer
- Defined in:
- lib/warming_drawer.rb,
lib/warming_drawer/version.rb,
lib/warming_drawer/configuration.rb,
lib/warming_drawer/workers/url_worker.rb,
lib/warming_drawer/workers/base_worker.rb
Defined Under Namespace
Modules: Workers Classes: Configuration
Constant Summary collapse
- VERSION =
"0.0.3"
Class Attribute Summary collapse
-
.configuration ⇒ Object
Returns the value of attribute configuration.
Class Method Summary collapse
- .configure {|configuration| ... } ⇒ Object
-
.use_queue? ⇒ Boolean
Returns true if a queuing system is defined.
-
.warm(*args) ⇒ Boolean
Warms a cache.
Class Attribute Details
.configuration ⇒ Object
Returns the value of attribute configuration.
9 10 11 |
# File 'lib/warming_drawer.rb', line 9 def configuration @configuration end |
Class Method Details
.configure {|configuration| ... } ⇒ Object
12 13 14 15 |
# File 'lib/warming_drawer.rb', line 12 def self.configure self.configuration ||= Configuration.new yield(configuration) end |
.use_queue? ⇒ Boolean
Returns true if a queuing system is defined
46 47 48 |
# File 'lib/warming_drawer.rb', line 46 def self.use_queue? configuration.queue_system != :inline end |
.warm(*args) ⇒ Boolean
Warms a cache. Delegates to the proper worker depending on the type. If being used within Rails, returns false unless action_controller caching is enabled.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/warming_drawer.rb', line 25 def self.warm(*args) return false unless cachable? if args.last.is_a?(Hash) = args.pop else = {} end [:type] ||= :url if worker = available_worker_for_type([:type]) # TODO: can this move into worker since its reading config? worker. queue: configuration.queue_name, retry: configuration.retry worker.perform_with(args) end !worker.nil? end |