Class: Reactive::ObserverWrapper
- Inherits:
-
Object
- Object
- Reactive::ObserverWrapper
show all
- Defined in:
- lib/rrx.rb
Instance Attribute Summary collapse
Instance Method Summary
collapse
Constructor Details
#initialize(target, parent, opts = {}) ⇒ ObserverWrapper
Returns a new instance of ObserverWrapper.
63
64
65
66
67
68
69
|
# File 'lib/rrx.rb', line 63
def initialize(target, parent, opts = {})
attributes.each do |name, default|
instance_variable_set(:"@#{name}", opts[name])
end
@target = target
@parent = AmbivalentRef.new(parent)
end
|
Instance Attribute Details
#parent ⇒ Object
Returns the value of attribute parent.
61
62
63
|
# File 'lib/rrx.rb', line 61
def parent
@parent
end
|
#target ⇒ Object
Returns the value of attribute target.
61
62
63
|
# File 'lib/rrx.rb', line 61
def target
@target
end
|
Instance Method Details
#active? ⇒ Boolean
94
95
96
|
# File 'lib/rrx.rb', line 94
def active?
@parent
end
|
#attributes ⇒ Object
71
72
73
|
# File 'lib/rrx.rb', line 71
def attributes
self.class.parent.attributes
end
|
#on_complete ⇒ Object
79
80
81
82
|
# File 'lib/rrx.rb', line 79
def on_complete
@target.on_complete
unwrap
end
|
#on_next(value) ⇒ Object
75
76
77
|
# File 'lib/rrx.rb', line 75
def on_next(value)
@target.on_next(value)
end
|
#unwrap ⇒ Object
88
89
90
91
92
|
# File 'lib/rrx.rb', line 88
def unwrap
attributes.each {|name, default| instance_variable_set(:"@#{name}", nil) }
@target = EmptyObserver.new
unwrap_parent if active?
end
|
#unwrap_parent(*args) ⇒ Object
98
99
100
|
# File 'lib/rrx.rb', line 98
def unwrap_parent(*args)
@parent.unwrap(*args)
end
|
#wrap_with_parent(child) ⇒ Object
84
85
86
|
# File 'lib/rrx.rb', line 84
def wrap_with_parent(child)
@parent.target = child
end
|