Class: Karafka::Web::Pro::Commanding::Request
- Inherits:
-
Object
- Object
- Karafka::Web::Pro::Commanding::Request
- 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
-
#[](key) ⇒ Object
Fetches the underlying details value and raises key error when not available.
-
#initialize(details) ⇒ Request
constructor
A new instance of Request.
-
#name ⇒ String
Name of the request.
-
#to_h ⇒ Hash
Raw details.
Constructor Details
#initialize(details) ⇒ Request
Returns a new instance of Request.
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
27 28 29 |
# File 'lib/karafka/web/pro/commanding/request.rb', line 27 def [](key) @details.fetch(key) end |
#name ⇒ String
Returns name of the request.
18 19 20 |
# File 'lib/karafka/web/pro/commanding/request.rb', line 18 def name self[:name] end |
#to_h ⇒ Hash
Returns raw details.
32 33 34 |
# File 'lib/karafka/web/pro/commanding/request.rb', line 32 def to_h @details end |