Class: Logux::Meta

Inherits:
Hash
  • Object
show all
Defined in:
lib/logux/meta.rb

Instance Method Summary collapse

Constructor Details

#initialize(source_hash = {}) ⇒ Meta

Returns a new instance of Meta.



5
6
7
8
9
10
# File 'lib/logux/meta.rb', line 5

def initialize(source_hash = {})
  merge!(source_hash.stringify_keys)

  self['id'] ||= Logux.generate_action_id
  self['time'] ||= self['id'].split(' ')[0]
end

Instance Method Details

#client_idObject



20
21
22
# File 'lib/logux/meta.rb', line 20

def client_id
  node_id.split(':')[0..1].join(':')
end

#idObject



32
33
34
# File 'lib/logux/meta.rb', line 32

def id
  fetch('id')
end

#logux_orderObject



24
25
26
# File 'lib/logux/meta.rb', line 24

def logux_order
  time + ' ' + id.split(' ')[1..-1].join(' ')
end

#node_idObject



12
13
14
# File 'lib/logux/meta.rb', line 12

def node_id
  id.split(' ')[1]
end

#timeObject



28
29
30
# File 'lib/logux/meta.rb', line 28

def time
  fetch('time')
end

#user_idObject



16
17
18
# File 'lib/logux/meta.rb', line 16

def user_id
  node_id.split(':')[0]
end