Class: Siffer::Messages::Header

Inherits:
AcDc::Body
  • Object
show all
Defined in:
lib/siffer/messages/header.rb

Class Method Summary collapse

Class Method Details

.create(options = {}) {|head| ... } ⇒ Object

Yields:

  • (head)


40
41
42
43
44
45
46
47
48
49
50
51
# File 'lib/siffer/messages/header.rb', line 40

def self.create(options = {}, &block)
  head = Header.new
  head.source_id = options[:source]
  head.msg_id = options[:msg_id] || UUID.generate(:compact).upcase
  head.timestamp = options[:timestamp] || Time.now.strftime("%Y-%m-%dT%H:%M:%SZ")
  head.security = Security.create(options)
  yield head if block_given?
  raise "Source is required for Header" if head.source_id.nil?
  raise "Message Id is required for Header" if head.msg_id.nil?
  raise "Timestamp is require for Header" if head.timestamp.nil?
  head
end