lib/unleash.rb in unleash-4.3.0 vs lib/unleash.rb in unleash-4.4.0
- old
+ new
@@ -1,35 +1,31 @@
require 'unleash/version'
require 'unleash/configuration'
-require 'unleash/strategy/base'
+require 'unleash/strategies'
require 'unleash/context'
require 'unleash/client'
require 'logger'
-Gem.find_files('unleash/strategy/**/*.rb').each{ |path| require path unless path.end_with? '_spec.rb' }
-
module Unleash
TIME_RESOLUTION = 3
- STRATEGIES = Unleash::Strategy.constants
- .select{ |c| Unleash::Strategy.const_get(c).is_a? Class }
- .reject{ |c| ['NotImplemented', 'Base'].include?(c.to_s) }
- .map do |c|
- lowered_c = c.to_s
- lowered_c[0] = lowered_c[0].downcase
- [lowered_c.to_sym, Object.const_get("Unleash::Strategy::#{c}").new]
- end
- .to_h
-
class << self
- attr_accessor :configuration, :toggle_fetcher, :toggles, :toggle_metrics, :reporter, :logger
+ attr_accessor :configuration, :toggle_fetcher, :toggles, :toggle_metrics, :reporter, :segment_cache, :logger
end
+ self.configuration = Unleash::Configuration.new
+
+ # Deprecated: Use Unleash.configure to add custom strategies
+ STRATEGIES = self.configuration.strategies
+
# Support for configuration via yield:
def self.configure
- self.configuration ||= Unleash::Configuration.new
yield(configuration)
self.configuration.validate!
self.configuration.refresh_backup_file!
+ end
+
+ def self.strategies
+ self.configuration.strategies
end
end