Class: Reactive::Observable::Grep::Observer
- Inherits:
-
Reactive::ObserverWrapper
- Object
- Reactive::ObserverWrapper
- Reactive::Observable::Grep::Observer
- Defined in:
- lib/Reactive/observable/grep.rb
Overview
def observer_args(observer, parent) [observer, parent, @predicate] end
Instance Attribute Summary collapse
-
#predicate ⇒ Object
readonly
Returns the value of attribute predicate.
Attributes inherited from Reactive::ObserverWrapper
Instance Method Summary collapse
-
#on_next(value) ⇒ Object
def initialize(value, parent, opts={}) @predicate = opts super(value, parent) end.
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
#predicate ⇒ Object (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 |