Class: ObservablePool::Observer
- Includes:
- Observable
- Defined in:
- lib/observable_pool.rb
Instance Attribute Summary collapse
- 
  
    
      #observable  ⇒ Object 
    
    
  
  
  
  
    
      readonly
    
    
  
  
  
  
  
  
    Returns the value of attribute observable. 
Instance Method Summary collapse
- 
  
    
      #initialize(observable, mutex)  ⇒ Observer 
    
    
  
  
  
    constructor
  
  
  
  
  
  
  
    A new instance of Observer. 
- #method_missing(meth, *args, &block) ⇒ Object
- #update(*args, &block) ⇒ Object
Methods included from Observable
#add_observers, included, #list_observers, #notify_observer, #observer?
Constructor Details
#initialize(observable, mutex) ⇒ Observer
Returns a new instance of Observer.
| 20 21 22 23 24 | # File 'lib/observable_pool.rb', line 20 def initialize(observable, mutex) @observable = observable @observable.add_observer(self) @mutex = mutex end | 
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args, &block) ⇒ Object
| 33 34 35 | # File 'lib/observable_pool.rb', line 33 def method_missing(meth, *args, &block) @observable.send(meth, *args, &block) end | 
Instance Attribute Details
#observable ⇒ Object (readonly)
Returns the value of attribute observable.
| 18 19 20 | # File 'lib/observable_pool.rb', line 18 def observable @observable end | 
Instance Method Details
#update(*args, &block) ⇒ Object
| 26 27 28 29 30 31 | # File 'lib/observable_pool.rb', line 26 def update(*args, &block) @mutex.synchronize do changed notify_observers(@observable, *args, &block) end end |