Class: Trifle::Logs::Operations::Dump

Inherits:
Object
  • Object
show all
Defined in:
lib/trifle/logs/operations/dump.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(**keywords) ⇒ Dump

Returns a new instance of Dump.



9
10
11
12
13
14
# File 'lib/trifle/logs/operations/dump.rb', line 9

def initialize(**keywords)
  @namespace = keywords.fetch(:namespace)
  @payload = keywords.fetch(:payload)
  @scope = keywords.fetch(:scope)
  @config = keywords[:config]
end

Instance Attribute Details

#namespaceObject (readonly)

Returns the value of attribute namespace.



7
8
9
# File 'lib/trifle/logs/operations/dump.rb', line 7

def namespace
  @namespace
end

#payloadObject (readonly)

Returns the value of attribute payload.



7
8
9
# File 'lib/trifle/logs/operations/dump.rb', line 7

def payload
  @payload
end

#scopeObject (readonly)

Returns the value of attribute scope.



7
8
9
# File 'lib/trifle/logs/operations/dump.rb', line 7

def scope
  @scope
end

Instance Method Details

#configObject



16
17
18
# File 'lib/trifle/logs/operations/dump.rb', line 16

def config
  @config || Trifle::Logs.default
end

#formattedObject



20
21
22
23
24
25
# File 'lib/trifle/logs/operations/dump.rb', line 20

def formatted
  [
    config.timestamp_formatter.format(Time.now),
    config.content_formatter.format(scope, payload)
  ].join(' ')
end

#performObject



27
28
29
30
31
# File 'lib/trifle/logs/operations/dump.rb', line 27

def perform
  config.driver.dump(
    formatted, namespace: namespace
  )
end