Class: Experimental::Loader
- Inherits:
-
Object
- Object
- Experimental::Loader
- Defined in:
- lib/experimental/loader.rb
Instance Attribute Summary collapse
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Loader
constructor
A new instance of Loader.
- #sync ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Loader
Returns a new instance of Loader.
5 6 7 |
# File 'lib/experimental/loader.rb', line 5 def initialize( = {}) @logger = [:logger] || Logger.new('/dev/null') end |
Instance Attribute Details
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
9 10 11 |
# File 'lib/experimental/loader.rb', line 9 def logger @logger end |
Instance Method Details
#sync ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/experimental/loader.rb', line 11 def sync logger.info "Synchronizing experiments..." Experimental::Experiment.transaction do all_experiments = Experimental::Experiment.in_code active_experiments = create_or_update_active_experiments if active_experiments.present? active_ids = active_experiments.map(&:id) remove(all_experiments.where('id NOT IN (?)', active_ids)) else remove(all_experiments) end end logger.info "Done." end |