Class: Unbreakable::Observers::Observer

Inherits:
Object
  • Object
show all
Defined in:
lib/unbreakable/observers/observer.rb

Overview

Abstract class for observers following the Ruby stdlib implementation of the Observer object-oriented design pattern. See Log for an example.

The following instance methods must be implemented in sub-classes:

  • update

Direct Known Subclasses

Log

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(observed) ⇒ Observer

Returns a new instance of Observer.

Parameters:

  • observed

    the observed object



15
16
17
# File 'lib/unbreakable/observers/observer.rb', line 15

def initialize(observed)
  @observed = observed
end

Instance Attribute Details

#observedObject (readonly)

Returns the value of attribute observed.



12
13
14
# File 'lib/unbreakable/observers/observer.rb', line 12

def observed
  @observed
end

Instance Method Details

#update(method, *args) ⇒ void

This method returns an undefined value.

Parameters:

  • method (Symbol)

    the method called on the observed object

  • args (Array)

    the arguments to the method

Raises:

  • (NotImplementedError)


22
23
24
# File 'lib/unbreakable/observers/observer.rb', line 22

def update(method, *args)
  raise NotImplementedError
end