Class: Reactive::Observable::Grep::Observer

Inherits:
Reactive::ObserverWrapper show all
Defined in:
lib/Reactive/observable/grep.rb

Overview

def observer_args(observer, parent) [observer, parent, @predicate] end

Instance Attribute Summary collapse

Attributes inherited from Reactive::ObserverWrapper

#parent, #target

Instance Method Summary collapse

Methods inherited from Reactive::ObserverWrapper

#active?, #attributes, #initialize, #on_complete, #unwrap, #unwrap_parent, #wrap_with_parent

Constructor Details

This class inherits a constructor from Reactive::ObserverWrapper

Instance Attribute Details

#predicateObject (readonly)

Returns the value of attribute predicate.



15
16
17
# File 'lib/Reactive/observable/grep.rb', line 15

def predicate
  @predicate
end

Instance Method Details

#on_next(value) ⇒ Object

def initialize(value, parent, opts={}) @predicate = opts super(value, parent) end



22
23
24
25
26
27
28
29
30
31
# File 'lib/Reactive/observable/grep.rb', line 22

def on_next(value)
  begin
    should_pass = @predicate.call(value)
  rescue Exception => e
    pp e
    on_error.call(e)
  else
    @target.on_next(value) if should_pass
  end
end