Class: MotionBindable::Strategy
- Inherits:
-
Object
- Object
- MotionBindable::Strategy
- Defined in:
- lib/motion_bindable/strategy.rb
Direct Known Subclasses
MotionBindable::Strategies::Proc, MotionBindable::Strategies::UILabel, MotionBindable::Strategies::UITextField
Instance Attribute Summary collapse
-
#attr_name ⇒ Object
readonly
Returns the value of attribute attr_name.
-
#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
-
#bound_value ⇒ Object
(also: #refresh_bound)
def start_observing; end def start_observing_bound; end def start_observing_object; end def on_object_change; end def on_bound_change; end.
-
#initialize(object, attr_name) ⇒ Strategy
constructor
A new instance of Strategy.
- #object_value ⇒ Object (also: #refresh_object)
- #unbind ⇒ Object
Constructor Details
#initialize(object, attr_name) ⇒ Strategy
Returns a new instance of Strategy.
19 20 21 22 |
# File 'lib/motion_bindable/strategy.rb', line 19 def initialize(object, attr_name) @attr_name = attr_name.to_sym self.object = object end |
Instance Attribute Details
#attr_name ⇒ Object (readonly)
Returns the value of attribute attr_name.
17 18 19 |
# File 'lib/motion_bindable/strategy.rb', line 17 def attr_name @attr_name end |
#bound ⇒ Object
Returns the value of attribute bound.
16 17 18 |
# File 'lib/motion_bindable/strategy.rb', line 16 def bound @bound end |
#object ⇒ Object
Returns the value of attribute object.
15 16 17 |
# File 'lib/motion_bindable/strategy.rb', line 15 def object @object end |
Class Method Details
.find_by_reference(object) ⇒ Object
9 10 11 12 13 |
# File 'lib/motion_bindable/strategy.rb', line 9 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
5 6 7 |
# File 'lib/motion_bindable/strategy.rb', line 5 def self.register_strategy(strategy, *objects) @strategies_map << { class: strategy, candidates: objects } end |
Instance Method Details
#bind(bound) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/motion_bindable/strategy.rb', line 38 def bind(bound) self.bound = bound initial_state start_listen self end |
#bound_value ⇒ Object Also known as: refresh_bound
def start_observing; end def start_observing_bound; end def start_observing_object; end def on_object_change; end def on_bound_change; end
32 33 |
# File 'lib/motion_bindable/strategy.rb', line 32 def bound_value end |
#object_value ⇒ Object Also known as: refresh_object
35 36 |
# File 'lib/motion_bindable/strategy.rb', line 35 def object_value end |
#unbind ⇒ Object
45 46 |
# File 'lib/motion_bindable/strategy.rb', line 45 def unbind end |