Sha256: 162374f7550216057f9f7205151d46a20ba0dce55048c1497e352c2da7d4561f

Contents?: true

Size: 593 Bytes

Versions: 1

Compression:

Stored size: 593 Bytes

Contents

# frozen_string_literal: true

module Logux
  class Meta < Hash
    def initialize(source_hash = {})
      merge!(source_hash.stringify_keys)

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

    def node_id
      id.split(' ').second
    end

    def user_id
      node_id.split(':').first
    end

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

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

    def time
      fetch('time')
    end

    def id
      fetch('id')
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
logux_rails-0.1.0 lib/logux/meta.rb