Class: SIF::Infra::Common::Message

Inherits:
Object
  • Object
show all
Defined in:
lib/sif/infra/common/message.rb

Instance Method Summary collapse

Instance Method Details

#contentObject



69
70
71
72
73
# File 'lib/sif/infra/common/message.rb', line 69

def content
  ack || event || provide || provision ||
  register || request || response || subscribe ||
  system_control || unprovide || unregister || unsubscribe
end

#datatypeObject



61
62
63
64
65
66
67
# File 'lib/sif/infra/common/message.rb', line 61

def datatype
  if response? && !response_objects.empty?
    inner_message.response.object_data.datatype
  elsif event? && event_object
    event_object.datatype
  end
end

#event?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/sif/infra/common/message.rb', line 33

def event?
  inner_message && !inner_message.event.nil?
end

#event_objectObject



51
52
53
54
55
# File 'lib/sif/infra/common/message.rb', line 51

def event_object
  inner_message.event.object_data.event_object
rescue NoMethodError
  nil
end

#final_packet?Boolean

Returns:

  • (Boolean)


37
38
39
# File 'lib/sif/infra/common/message.rb', line 37

def final_packet?
  response? && !inner_message.response.more_packets?
end

#inner_messageObject



23
24
25
26
27
# File 'lib/sif/infra/common/message.rb', line 23

def inner_message
  ack.status.data.message
rescue NoMethodError
  nil
end

#msg_idObject



79
80
81
# File 'lib/sif/infra/common/message.rb', line 79

def msg_id
  content && content.header.msg_id
end

#request_msg_idObject



41
42
43
# File 'lib/sif/infra/common/message.rb', line 41

def request_msg_id
  response? && inner_message.response.request_msg_id
end

#response?Boolean

Returns:

  • (Boolean)


29
30
31
# File 'lib/sif/infra/common/message.rb', line 29

def response?
  inner_message && !inner_message.response.nil?
end

#response_objectsObject



45
46
47
48
49
# File 'lib/sif/infra/common/message.rb', line 45

def response_objects
  inner_message.response.object_data.objects
rescue NoMethodError
  nil
end

#source_idObject



75
76
77
# File 'lib/sif/infra/common/message.rb', line 75

def source_id
  content && content.header.source_id
end

#status_codeObject



87
88
89
# File 'lib/sif/infra/common/message.rb', line 87

def status_code
  ack && ack.status.code
end

#timestampObject



83
84
85
# File 'lib/sif/infra/common/message.rb', line 83

def timestamp
  content && content.header.timestamp
end

#typeObject



57
58
59
# File 'lib/sif/infra/common/message.rb', line 57

def type
  if event then :event else :response end
end