Class: Rookout::Augs::AugsManager
- Inherits:
-
Object
- Object
- Rookout::Augs::AugsManager
- Defined in:
- lib/rookout/augs/augs_manager.rb
Instance Method Summary collapse
- #add_aug(configuration) ⇒ Object
- #clear_augs ⇒ Object
-
#initialize(trigger_services, output) ⇒ AugsManager
constructor
A new instance of AugsManager.
- #initialize_augs(augs) ⇒ Object
- #remove_aug(aug_id) ⇒ Object
Constructor Details
#initialize(trigger_services, output) ⇒ AugsManager
Returns a new instance of AugsManager.
10 11 12 13 14 15 |
# File 'lib/rookout/augs/augs_manager.rb', line 10 def initialize trigger_services, output @trigger_services = trigger_services @output = output @aug_factory = AugFactory.new @output @augs = [] end |
Instance Method Details
#add_aug(configuration) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/rookout/augs/augs_manager.rb', line 35 def add_aug configuration begin aug = @aug_factory.create_aug configuration rescue StandardError => e = "Failed to parse aug" Logger.instance.exception , e begin aug_id = configuration["id"] rescue StandardError return end error = Rookout::Processor::RookError.new e, @output.send_rule_status aug_id, "Error", error return end if @augs.include? aug.id Logger.instance.debug "Aug already set - #{aug.id}" return end Logger.instance.debug "Adding aug-\t#{aug.id}" aug.add_aug @trigger_services @augs.push aug.id end |
#clear_augs ⇒ Object
71 72 73 74 75 76 |
# File 'lib/rookout/augs/augs_manager.rb', line 71 def clear_augs Logger.instance.debug "Clearing all augs" @augs.clone.each { |aug| remove_aug aug } @trigger_services.clear_augs end |
#initialize_augs(augs) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/rookout/augs/augs_manager.rb', line 17 def initialize_augs augs leftovers = @augs.clone augs.each do |aug| begin aug_id = aug["id"] rescue KeyError next end leftovers.delete aug_id add_aug aug end leftovers.each { |aug_id| remove_aug aug_id } end |
#remove_aug(aug_id) ⇒ Object
64 65 66 67 68 69 |
# File 'lib/rookout/augs/augs_manager.rb', line 64 def remove_aug aug_id Logger.instance.debug "Removing aug-\t#{aug_id}" @trigger_services.remove_aug aug_id @augs.delete aug_id end |