Class: Stenotype::ContextHandlers::Base Abstract
- Inherits:
-
Object
- Object
- Stenotype::ContextHandlers::Base
- Defined in:
- lib/stenotype/context_handlers/base.rb
Overview
This class is abstract.
An abstract base class for implementing contexts handlers
Direct Known Subclasses
Class Attribute Summary collapse
-
.handler_name ⇒ Symbol
Name of the handler.
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
A context in which the event was emitted.
-
#options ⇒ Hash
readonly
A hash of additional options.
Class Method Summary collapse
Instance Method Summary collapse
-
#as_json(*_args) ⇒ Object
abstract
-
#initialize(context, options: {}) ⇒ #as_json
constructor
A context handler implementing [#as_json].
Constructor Details
#initialize(context, options: {}) ⇒ #as_json
Returns A context handler implementing [#as_json].
37 38 39 40 |
# File 'lib/stenotype/context_handlers/base.rb', line 37 def initialize(context, options: {}) @context = context @options = end |
Class Attribute Details
.handler_name ⇒ Symbol
Returns Name of the handler.
61 62 63 |
# File 'lib/stenotype/context_handlers/base.rb', line 61 def handler_name @handler_name || raise(NotImplementedError, "Please, specify the handler_name of #{self}") end |
Instance Attribute Details
#context ⇒ Object (readonly)
A context in which the event was emitted
24 25 26 |
# File 'lib/stenotype/context_handlers/base.rb', line 24 def context @context end |
#options ⇒ Hash (readonly)
A hash of additional options
24 25 26 |
# File 'lib/stenotype/context_handlers/base.rb', line 24 def @options end |
Class Method Details
.inherited(subklass) ⇒ Object
27 28 29 |
# File 'lib/stenotype/context_handlers/base.rb', line 27 def self.inherited(subklass) ContextHandlers.register(subklass) end |
Instance Method Details
#as_json(*_args) ⇒ Object
This method is abstract.
46 47 48 |
# File 'lib/stenotype/context_handlers/base.rb', line 46 def as_json(*_args) raise NotImplementedError, "#{self} must implement method ##{__method__}" end |