Module: Rgtk::Controller::DSL
- Included in:
- Base
- Defined in:
- lib/rgtk/controller/dsl.rb
Instance Method Summary collapse
- #on(action, &block) ⇒ Object (also: #signal)
- #shortcuts(shortcut_hash) ⇒ Object
- #signals_for(object) ⇒ Object
Instance Method Details
#on(action, &block) ⇒ Object Also known as: signal
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/rgtk/controller/dsl.rb', line 18 def on(action, &block) callback_name = "#{signal_prefix}_#{action}" defined = instance_method(callback_name) rescue false raise "#{callback_name} is already defined in #{self}" if defined if block_given? define_method(callback_name, &block) else define_method(callback_name) do flunk "No implementation provided for #{callback_name}" end end end |
#shortcuts(shortcut_hash) ⇒ Object
4 5 6 7 8 9 10 |
# File 'lib/rgtk/controller/dsl.rb', line 4 def shortcuts(shortcut_hash) shortcut_hash.each do |key, name| define_method key do builder.get_object(name) end end end |
#signals_for(object) ⇒ Object
12 13 14 15 16 |
# File 'lib/rgtk/controller/dsl.rb', line 12 def signals_for(object) _current_object.push(object) yield _current_object.pop end |