Class: Lbrt::Alert::Exporter
- Inherits:
-
Object
- Object
- Lbrt::Alert::Exporter
- Defined in:
- lib/lbrt/alert/exporter.rb
Class Method Summary collapse
Instance Method Summary collapse
- #export ⇒ Object
-
#initialize(client, options = {}) ⇒ Exporter
constructor
of class methods.
- #normalize(alerts) ⇒ Object
Constructor Details
#initialize(client, options = {}) ⇒ Exporter
of class methods
8 9 10 11 |
# File 'lib/lbrt/alert/exporter.rb', line 8 def initialize(client, = {}) @client = client @options = end |
Class Method Details
.export(client, options = {}) ⇒ Object
3 4 5 |
# File 'lib/lbrt/alert/exporter.rb', line 3 def export(client, = {}) self.new(client, ).export end |
Instance Method Details
#export ⇒ Object
13 14 15 16 |
# File 'lib/lbrt/alert/exporter.rb', line 13 def export alerts = @client.alerts.get normalize(alerts) end |
#normalize(alerts) ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/lbrt/alert/exporter.rb', line 18 def normalize(alerts) alert_by_name = {} alerts.each do |alrt| name = alrt.delete('name') if alert_by_name[name] raise "Duplicate alert name exists: #{name}" end %w(created_at updated_at version).each do |key| alrt.delete(key) end alrt['attributes'] ||= {} alert_by_name[name] = alrt end alert_by_name end |