Sha256: 018ac8425544e68e0476747afa9e181e3fa81c73729ee484ec6eae41ee738668

Contents?: true

Size: 733 Bytes

Versions: 2

Compression:

Stored size: 733 Bytes

Contents

class Sysdig::UserNotifications < Sysdig::Collection

  model Sysdig::UserNotification

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

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

  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
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
sysdig-0.2.3 lib/sysdig/user_notifications.rb
sysdig-0.2.0 lib/sysdig/user_notifications.rb