Module: RMExtensions::ObjectExtensions::Observation
- Defined in:
- lib/motion/observation.rb
Instance Method Summary collapse
-
#rmext_cleanup ⇒ Object
remove all observations and event callbacks on this object.
- #rmext_observation_proxy ⇒ Object
- #rmext_observe(object, keyPath: key, options: options, withBlock: block) ⇒ Object
- #rmext_observe_passive(object, keyPath: key, withBlock: block) ⇒ Object
-
#rmext_off(event, inContext: context, withBlock: block) ⇒ Object
remove a specific callback for an event on this object.
-
#rmext_off_all ⇒ Object
remove all event callbacks on this object.
-
#rmext_on(event, inContext: context, withBlock: block) ⇒ Object
register a callback when an event is trigger on this object.
-
#rmext_trigger(event, value = nil) ⇒ Object
trigger an event with value on this object.
-
#rmext_unobserve(object, keyPath: key) ⇒ Object
unobserve an existing observation.
-
#rmext_unobserve_all ⇒ Object
unobserve all existing observations.
Instance Method Details
#rmext_cleanup ⇒ Object
remove all observations and event callbacks on this object
64 65 66 67 68 |
# File 'lib/motion/observation.rb', line 64 def rmext_cleanup if @rmext_observation_proxy @rmext_observation_proxy.cleanup end end |
#rmext_observation_proxy ⇒ Object
7 8 9 |
# File 'lib/motion/observation.rb', line 7 def rmext_observation_proxy @rmext_observation_proxy ||= ObservationProxy.new(self) end |
#rmext_observe(object, keyPath: key, options: options, withBlock: block) ⇒ Object
15 16 17 |
# File 'lib/motion/observation.rb', line 15 def rmext_observe(object, keyPath:key, withBlock:block) rmext_observe(object, keyPath:key, options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld | NSKeyValueObservingOptionInitial), withBlock:block) end |
#rmext_observe_passive(object, keyPath: key, withBlock: block) ⇒ Object
11 12 13 |
# File 'lib/motion/observation.rb', line 11 def rmext_observe_passive(object, keyPath:key, withBlock:block) rmext_observe(object, keyPath:key, options:(NSKeyValueObservingOptionNew | NSKeyValueObservingOptionOld), withBlock:block) end |
#rmext_off(event, inContext: context, withBlock: block) ⇒ Object
remove a specific callback for an event on this object
43 44 45 46 47 |
# File 'lib/motion/observation.rb', line 43 def rmext_off(event, inContext:context, withBlock:block) if @rmext_observation_proxy @rmext_observation_proxy.off(event, inContext:context, withBlock:block) end end |
#rmext_off_all ⇒ Object
remove all event callbacks on this object
50 51 52 53 54 |
# File 'lib/motion/observation.rb', line 50 def rmext_off_all if @rmext_observation_proxy @rmext_observation_proxy.off_all end end |
#rmext_on(event, inContext: context, withBlock: block) ⇒ Object
register a callback when an event is trigger on this object
38 39 40 |
# File 'lib/motion/observation.rb', line 38 def rmext_on(event, inContext:context, withBlock:block) rmext_observation_proxy.on(event, inContext:context, withBlock:block) end |
#rmext_trigger(event, value = nil) ⇒ Object
trigger an event with value on this object
57 58 59 60 61 |
# File 'lib/motion/observation.rb', line 57 def rmext_trigger(event, value=nil) if @rmext_observation_proxy @rmext_observation_proxy.trigger(event, value) end end |
#rmext_unobserve(object, keyPath: key) ⇒ Object
unobserve an existing observation
24 25 26 27 28 |
# File 'lib/motion/observation.rb', line 24 def rmext_unobserve(object, keyPath:key) if @rmext_observation_proxy @rmext_observation_proxy.unobserve(object, keyPath:key) end end |
#rmext_unobserve_all ⇒ Object
unobserve all existing observations
31 32 33 34 35 |
# File 'lib/motion/observation.rb', line 31 def rmext_unobserve_all if @rmext_observation_proxy @rmext_observation_proxy.unobserve_all end end |