Module: HotCocoa::Mappings::TargetActionConvenience
- Defined in:
- lib/hotcocoa/target_action_convenience.rb
Overview
This module should be mixed into mappings that want to support target actions.
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.perform_action(sender) ⇒ Object
24 25 26 |
# File 'lib/hotcocoa/target_action_convenience.rb', line 24 def @object.perform_action sender @action_behavior.call sender end |
Instance Method Details
#on_action {|sender| ... } ⇒ Object
TODO:
testing
35 36 37 38 |
# File 'lib/hotcocoa/target_action_convenience.rb', line 35 def on_action &behavior self.on_action = behavior self end |
#on_action=(behavior) ⇒ Object
TODO:
testing
10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/hotcocoa/target_action_convenience.rb', line 10 def on_action= behavior if target && ( target.instance_variable_get(:@action_behavior) || target.instance_variable_get(:@double_action_behavior)) @object.instance_variable_set(:@action_behavior, behavior) @object = target else @object = Object.new @object.instance_variable_set(:@action_behavior, behavior) setTarget(@object) end def @object.perform_action sender @action_behavior.call sender end setAction('perform_action:') end |