|
|
@ -6,15 +6,17 @@ class MethodContainer |
|
|
|
@method_registry = [] |
|
|
|
@method_registry = [] |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
# Empty method that does nothing (placeholder for keyhooks) |
|
|
|
|
|
|
|
def nullmethod |
|
|
|
|
|
|
|
return nil |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create_method(name, &block) |
|
|
|
def create_method(name, &block) |
|
|
|
method_registry << name |
|
|
|
method_registry << name |
|
|
|
self.class.send(:define_method, name, &block) |
|
|
|
self.class.send(:define_method, name, &block) |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def call(method_name, *args) |
|
|
|
|
|
|
|
debug("Calling method '#{method_name}' for #{self}") |
|
|
|
|
|
|
|
if( @method_registry.include? method_name ) then |
|
|
|
|
|
|
|
self.send(method_name, *args) |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
class KeyHook |
|
|
|
class KeyHook |
|
|
@ -36,10 +38,12 @@ class KeyHook |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def call(hook, *args) |
|
|
|
def call(hook, *args) |
|
|
|
|
|
|
|
if( @key_hooks.key? hook ) then |
|
|
|
@key_hooks[hook].each do |event_name| |
|
|
|
@key_hooks[hook].each do |event_name| |
|
|
|
@method_container.send(event_name, *args) |
|
|
|
@method_container.send(event_name, *args) |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
end |
|
|
|
|
|
|
|
|
|
|
|
def get_hooks |
|
|
|
def get_hooks |
|
|
|
return self.key_hooks |
|
|
|
return self.key_hooks |
|
|
|