Class: UU::OS::GVC::Message

Inherits:
Object
  • Object
show all
Defined in:
uu_os_gvc-0.28.16/lib/uu/os/gvc/message.rb

Overview

GVC message (used by components)

Defined Under Namespace

Classes: MessageSeverity

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Message) initialize(data = nil)

Creates new instance of message.

Parameters:

  • data (String, Hash) (defaults to: nil)

    Initialization data in form of JSON string or Hash (optional)



29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# File 'uu_os_gvc-0.28.16/lib/uu/os/gvc/message.rb', line 29

def initialize(data = nil)
  if data.nil?
    @raw_attrs = {}
    return
  end
  if data.kind_of?String
    data = JSON.parse(data, :symbolize_names => true)
  end
  if data.kind_of?Hash
    @raw_attrs = data
  elsif data.kind_of?Message
    if data.raw_attrs
      @raw_attrs = data.raw_attrs
    else
      @raw_attrs = {}
    end
  else
    raise ArgumentError.new("Message data must be JSON String or Hash, but was #{data.class}.")
  end
  if !@raw_attrs[:relatedTo]
    @raw_attrs[:relatedTo] = []
  end
end

Instance Attribute Details

- (Object) code

Message code.



18
19
20
# File 'uu_os_gvc-0.28.16/lib/uu/os/gvc/message.rb', line 18

def code
  @code
end

ID of component which message belongs to.



15
16
17
# File 'uu_os_gvc-0.28.16/lib/uu/os/gvc/message.rb', line 15

def related_to
  @related_to
end

- (Object) severity

Message severity. Allowed values MessageSeverity.



21
22
23
# File 'uu_os_gvc-0.28.16/lib/uu/os/gvc/message.rb', line 21

def severity
  @severity
end

- (Object) text

Message text.



24
25
26
# File 'uu_os_gvc-0.28.16/lib/uu/os/gvc/message.rb', line 24

def text
  @text
end