class MotionBindable::Strategies::Proc
Constants
- WATCH_TICK
Public Instance Methods
bound_value()
click to toggle source
# File lib/strategies/proc.rb, line 5 def bound_value bound.call end
object_value()
click to toggle source
# File lib/strategies/proc.rb, line 9 def object_value attribute end
on_bound_change(new = nil)
click to toggle source
# File lib/strategies/proc.rb, line 13 def on_bound_change(new = nil) self.attribute = new || bound.call end
start_observing()
click to toggle source
# File lib/strategies/proc.rb, line 22 def start_observing @watching = true watch end
unbind()
click to toggle source
Calls superclass method
# File lib/strategies/proc.rb, line 17 def unbind @watching = false super end
Private Instance Methods
dispatcher()
click to toggle source
# File lib/strategies/proc.rb, line 40 def dispatcher @dispatcher ||= begin Dispatch::Queue.concurrent 'org.motion.bindable' end end
watch()
click to toggle source
# File lib/strategies/proc.rb, line 29 def watch dispatcher.async do if @watching new = bound_value on_bound_change(new) if new != @old_bound_value @old_bound_value = nil dispatcher.after(WATCH_TICK) { watch } end end end