Class: Sysdig::UserNotifications

Inherits:
Collection
  • Object
show all
Defined in:
lib/sysdig/user_notifications.rb

Instance Method Summary collapse

Instance Method Details

#all(options = {}) ⇒ Object



5
6
7
# File 'lib/sysdig/user_notifications.rb', line 5

def all(options={})
  load(service.get_user_notifications.body.fetch("userNotification")).tap { |_| self.records.compact! }
end

#get(type) ⇒ Object



9
10
11
# File 'lib/sysdig/user_notifications.rb', line 9

def get(type)
  all.find { |r| r.identity == type.to_s }
end

#new(args) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/sysdig/user_notifications.rb', line 13

def new(args)
  type, attributes = *args

  unless attributes.is_a?(::Hash)
    raise(ArgumentError.new("Initialization parameters must be an attributes hash, got #{attributes.class} #{attributes.inspect}"))
  end

  concrete_model = model.types[type]

  if concrete_model
    concrete_model.new(
      {
        :collection => self,
        :service    => service,
      }.merge(attributes)
    )
  end
end