Class: MotionBindable::Strategy
- Inherits:
-
Object
- Object
- MotionBindable::Strategy
- Defined in:
- lib/motion_bindable/strategy.rb
Direct Known Subclasses
MotionBindable::Strategies::Proc, MotionBindable::Strategies::UITextField
Constant Summary collapse
- WATCH_TICK =
0.2
Instance Attribute Summary collapse
-
#bound ⇒ Object
Returns the value of attribute bound.
-
#object ⇒ Object
Returns the value of attribute object.
Class Method Summary collapse
Instance Method Summary collapse
-
#bind(bound) ⇒ Object
def start_observing_bound; end def start_observing_object; end def refresh_bound; end def on_object_change; end def on_bound_change; end.
-
#initialize(object, attr_name) ⇒ Strategy
constructor
A new instance of Strategy.
- #refresh_object ⇒ Object
- #unbind ⇒ Object
Constructor Details
#initialize(object, attr_name) ⇒ Strategy
Returns a new instance of Strategy.
22 23 24 25 |
# File 'lib/motion_bindable/strategy.rb', line 22 def initialize(object, attr_name) @attr_name = attr_name.to_sym self.object = object end |
Instance Attribute Details
#bound ⇒ Object
Returns the value of attribute bound.
20 21 22 |
# File 'lib/motion_bindable/strategy.rb', line 20 def bound @bound end |
#object ⇒ Object
Returns the value of attribute object.
19 20 21 |
# File 'lib/motion_bindable/strategy.rb', line 19 def object @object end |
Class Method Details
.find_by_reference(object) ⇒ Object
13 14 15 16 17 |
# File 'lib/motion_bindable/strategy.rb', line 13 def self.find_by_reference(object) @strategies_map.reverse.find do |h| h[:candidates].one? { |e| object.is_a? e } end.fetch(:class) end |
.register_strategy(strategy, *objects) ⇒ Object
9 10 11 |
# File 'lib/motion_bindable/strategy.rb', line 9 def self.register_strategy(strategy, *objects) @strategies_map << { class: strategy, candidates: objects } end |
Instance Method Details
#bind(bound) ⇒ Object
def start_observing_bound; end def start_observing_object; end def refresh_bound; end def on_object_change; end def on_bound_change; end
35 36 37 38 39 40 |
# File 'lib/motion_bindable/strategy.rb', line 35 def bind(bound) self.bound = bound initial_state start_listen self end |
#refresh_object ⇒ Object
42 43 44 |
# File 'lib/motion_bindable/strategy.rb', line 42 def refresh_object attribute end |
#unbind ⇒ Object
46 47 48 |
# File 'lib/motion_bindable/strategy.rb', line 46 def unbind @watching = nil end |