Class: GlassOctopus::Context
- Inherits:
-
Object
- Object
- GlassOctopus::Context
- 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
-
#logger ⇒ Object
A logger object.
-
#message ⇒ Message
readonly
A message read from Kafka.
Instance Method Summary collapse
-
#[](key) ⇒ Object
Retrieves the
value
object corresponding to thekey
object. -
#[]=(key, value) ⇒ Object
Associates
value
withkey
.
Instance Attribute Details
#logger ⇒ Object
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(, logger) @data = {} @message = @logger = logger end end |
#message ⇒ Message (readonly)
A message read from Kafka.
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(, logger) @data = {} @message = @logger = logger end end |
Instance Method Details
#[](key) ⇒ Object
Retrieves the value
object corresponding to the key
object.
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, :[], :[]= |