Class: Karafka::Web::Pro::Commanding::Request

Inherits:
Object
  • Object
show all
Defined in:
lib/karafka/web/pro/commanding/request.rb

Overview

Encapsulates the command request details not to use a raw hash

Instance Method Summary collapse

Constructor Details

#initialize(details) ⇒ Request

Returns a new instance of Request.

Parameters:

  • details (Hash)

    raw request details



13
14
15
# File 'lib/karafka/web/pro/commanding/request.rb', line 13

def initialize(details)
  @details = details
end

Instance Method Details

#[](key) ⇒ Object

Fetches the underlying details value and raises key error when not available

Parameters:

  • key (Symbol)

Returns:

  • (Object)

Raises:

  • (KeyError)


27
28
29
# File 'lib/karafka/web/pro/commanding/request.rb', line 27

def [](key)
  @details.fetch(key)
end

#nameString

Returns name of the request.

Returns:

  • (String)

    name of the request



18
19
20
# File 'lib/karafka/web/pro/commanding/request.rb', line 18

def name
  self[:name]
end

#to_hHash

Returns raw details.

Returns:

  • (Hash)

    raw details



32
33
34
# File 'lib/karafka/web/pro/commanding/request.rb', line 32

def to_h
  @details
end