Sha256: 3214eb21eb929e98eb564e7be2f93fa6043a6c100032bbe1f8bb25d77e5bcf88
Contents?: true
Size: 1.5 KB
Versions: 1
Compression:
Stored size: 1.5 KB
Contents
# frozen_string_literal: true module Stenotype module ContextHandlers # # An abstract base class for implementing contexts handlers # # @abstract # @attr_reader {Object} context A context in which the event was emitted # @attr_reader {Hash} options A hash of additional options # class Base attr_reader :context, :options # # @param context {Object} A context where the event was emitted # @param options {Hash} A hash of additional options # # @return {#as_json} A context handler implementing [#as_json] # def initialize(context, options = {}) @context = context @options = options end # # @abstract # @raise {NotImplementedError} subclasses must implement this method # def as_json(*_args) raise NotImplementedError, "#{self} must implement method ##{__method__}" end # # @attr_writer {Symbol} handler_name The name under which a handler is going to be registered # class << self # Handler name by which it will be registered in {Stenotype::ContextHandlers::Collection} attr_writer :handler_name # # @return {Symbol} Name of the handler # @raise {NotImplementedError} in case handler name is not specified. # def handler_name @handler_name || raise(NotImplementedError, "Please, specify the handler_name of #{self}") end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
stenotype-0.1.0 | lib/stenotype/context_handlers/base.rb |