Class: Substation::Observer Abstract

Inherits:
Object
  • Object
show all
Includes:
AbstractType, Adamantium::Flat
Defined in:
lib/substation/observer.rb

Overview

This class is abstract.

Abstract observer base class

Direct Known Subclasses

Chain

Defined Under Namespace

Classes: Chain

Constant Summary collapse

NULL =

Null observer

Class.new(self) { def call(_response); self; end; }.new.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.coerce(input) ⇒ Observer::NULL, ...

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Coerce input to an instance of Substation::Observer

Parameters:

  • input (NilClass, String, Array<String>)

    0..n observer class names

Returns:



30
31
32
33
34
35
36
37
38
39
# File 'lib/substation/observer.rb', line 30

def self.coerce(input)
  case input
  when NilClass
    NULL
  when Array
    Chain.new(input.map { |item| coerce(item) })
  else
    Utils.coerce_callable(input)
  end
end

Instance Method Details

#callself

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Notify the observer

Parameters:

  • response (Response)

    the response returned when calling the observed action

Returns:

  • (self)


19
# File 'lib/substation/observer.rb', line 19

abstract_method :call