Class: Rox::Core::FlagSetter
- Inherits:
-
Object
- Object
- Rox::Core::FlagSetter
- Defined in:
- lib/rox/core/entities/flag_setter.rb
Instance Method Summary collapse
-
#initialize(flag_repository, parser, experiment_repository, impression_invoker) ⇒ FlagSetter
constructor
A new instance of FlagSetter.
- #set_experiments ⇒ Object
- #set_flag_data(string, experiment = nil) ⇒ Object
Constructor Details
#initialize(flag_repository, parser, experiment_repository, impression_invoker) ⇒ FlagSetter
Returns a new instance of FlagSetter.
4 5 6 7 8 9 10 11 12 13 14 |
# File 'lib/rox/core/entities/flag_setter.rb', line 4 def initialize(flag_repository, parser, experiment_repository, impression_invoker) @flag_repository = flag_repository @parser = parser @experiment_repository = experiment_repository @impression_invoker = impression_invoker @flag_repository.register_flag_added_handler do |string| exp = @experiment_repository.experiment_by_flag(string.name) set_flag_data(string, exp) end end |
Instance Method Details
#set_experiments ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/rox/core/entities/flag_setter.rb', line 16 def set_experiments flags_with_condition = [] @experiment_repository.all_experiments.each do |exp| exp.flags.each do |flag_name| flag = @flag_repository.flag(flag_name) unless flag.nil? set_flag_data(flag, exp) flags_with_condition << flag_name end end end @flag_repository.all_flags.each do |flag| set_flag_data(flag) unless flags_with_condition.include?(flag.name) end end |
#set_flag_data(string, experiment = nil) ⇒ Object
34 35 36 |
# File 'lib/rox/core/entities/flag_setter.rb', line 34 def set_flag_data(string, experiment = nil) string.set_for_evaluation(@parser, experiment, @impression_invoker) end |