Class: Ynl::Models::Notification

Inherits:
Object
  • Object
show all
Defined in:
ynl/lib/ynl/models.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(kind:, message:, source:, group:) ⇒ Notification

Returns a new instance of Notification.



190
191
192
193
194
195
# File 'ynl/lib/ynl/models.rb', line 190

def initialize(kind:, message:, source:, group:)
  @kind = kind
  @message = message
  @source = source
  @group = group
end

Instance Attribute Details

#group ⇒ Object (readonly)

Returns the value of attribute group.



188
189
190
# File 'ynl/lib/ynl/models.rb', line 188

def group
  @group
end

#kind ⇒ Object (readonly)

Returns the value of attribute kind.



188
189
190
# File 'ynl/lib/ynl/models.rb', line 188

def kind
  @kind
end

#message ⇒ Object (readonly)

Returns the value of attribute message.



188
189
190
# File 'ynl/lib/ynl/models.rb', line 188

def message
  @message
end

#source ⇒ Object (readonly)

Returns the value of attribute source.



188
189
190
# File 'ynl/lib/ynl/models.rb', line 188

def source
  @source
end

Instance Method Details

#resolve(f) ⇒ Object



197
198
199
200
201
202
203
204
# File 'ynl/lib/ynl/models.rb', line 197

def resolve(f)
  @message = @message.resolve(f)
  @source = f.operations.fetch(@source) if @source
  @group = f.mcast_groups.fetch(@group) if @group
  self
rescue KeyError => error
  raise ParseError, "Failed to resolve #{kind} notification: #{error.message}"
end