Class: MotionBindable::Strategies::Proc

Inherits:
MotionBindable::Strategy show all
Defined in:
lib/strategies/proc.rb

Constant Summary collapse

WATCH_TICK =
0.2

Instance Attribute Summary

Attributes inherited from MotionBindable::Strategy

#attr_name, #bound, #object

Instance Method Summary collapse

Methods inherited from MotionBindable::Strategy

#bind, find_by_reference, #initialize, register_strategy

Constructor Details

This class inherits a constructor from MotionBindable::Strategy

Instance Method Details

#bound_valueObject



5
6
7
# File 'lib/strategies/proc.rb', line 5

def bound_value
  bound.call
end

#object_valueObject



9
10
11
# File 'lib/strategies/proc.rb', line 9

def object_value
  attribute
end

#on_bound_change(new = nil) ⇒ Object



13
14
15
# File 'lib/strategies/proc.rb', line 13

def on_bound_change(new = nil)
  self.attribute = new || bound.call
end

#start_observingObject



22
23
24
25
# File 'lib/strategies/proc.rb', line 22

def start_observing
  @watching = true
  watch
end

#unbindObject



17
18
19
20
# File 'lib/strategies/proc.rb', line 17

def unbind
  @watching = false
  super
end