Class: Copyleaks::Notifications

Inherits:
Object
  • Object
show all
Defined in:
lib/copyleaks/models/submissions/webhooks/HelperModels/CompletedModels/Notifications.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(alerts: nil) ⇒ Notifications

Returns a new instance of Notifications.

Parameters:

  • alerts (Array<Alerts>) (defaults to: nil)
    • A list of scan alerts that were detected in the scan.



25
26
27
28
29
30
31
# File 'lib/copyleaks/models/submissions/webhooks/HelperModels/CompletedModels/Notifications.rb', line 25

def initialize(alerts: nil)
  if !alerts.nil? && !(alerts.is_a?(Array) && alerts.all? { |a| a.is_a?(Alerts) })
    raise 'Copyleaks::Notifications - alerts must be an array of Alerts objects'
  end

  @alerts = alerts
end

Instance Attribute Details

#alertsObject (readonly)

Returns the value of attribute alerts.



22
23
24
# File 'lib/copyleaks/models/submissions/webhooks/HelperModels/CompletedModels/Notifications.rb', line 22

def alerts
  @alerts
end

Instance Method Details

#as_json(*_args) ⇒ Object



33
34
35
36
37
# File 'lib/copyleaks/models/submissions/webhooks/HelperModels/CompletedModels/Notifications.rb', line 33

def as_json(*_args)
  {
    alerts: @alerts
  }.select { |_k, v| !v.nil? }
end

#to_json(*options) ⇒ Object



39
40
41
# File 'lib/copyleaks/models/submissions/webhooks/HelperModels/CompletedModels/Notifications.rb', line 39

def to_json(*options)
  as_json(*options).to_json(*options)
end