Class: GlassOctopus::Context

Inherits:
Object
  • Object
show all
Extended by:
Forwardable
Defined in:
lib/glass_octopus/context.rb

Overview

Message context. Wraps a Kafka message and adds some convenience methods.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#loggerObject

A logger object. Defaults to the application logger.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/glass_octopus/context.rb', line 11

class Context
  extend Forwardable
  attr_reader :message
  attr_accessor :logger

  # @!method [](key)
  #   Retrieves the +value+ object corresponding to the +key+ object.
  #   @param key key to retrieve
  # @!method []=(key, value)
  #   Associates +value+ with +key+.
  def_delegators :@data, :[], :[]=

  # @api private
  def initialize(message, logger)
    @data    = {}
    @message = message
    @logger  = logger
  end
end

#messageMessage (readonly)

A message read from Kafka.

Returns:



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/glass_octopus/context.rb', line 11

class Context
  extend Forwardable
  attr_reader :message
  attr_accessor :logger

  # @!method [](key)
  #   Retrieves the +value+ object corresponding to the +key+ object.
  #   @param key key to retrieve
  # @!method []=(key, value)
  #   Associates +value+ with +key+.
  def_delegators :@data, :[], :[]=

  # @api private
  def initialize(message, logger)
    @data    = {}
    @message = message
    @logger  = logger
  end
end

Instance Method Details

#[](key) ⇒ Object

Retrieves the value object corresponding to the key object.

Parameters:

  • key

    key to retrieve



21
# File 'lib/glass_octopus/context.rb', line 21

def_delegators :@data, :[], :[]=

#[]=(key, value) ⇒ Object

Associates value with key.



21
# File 'lib/glass_octopus/context.rb', line 21

def_delegators :@data, :[], :[]=