Module: Rhoconnect::Handler::Helpers::Binding

Included in:
Authenticate::Runner, Changes::Engine, PluginCallbacks::Runner, Query::Engine, Search::Engine, Model::Base
Defined in:
lib/rhoconnect/handler/helpers/binding.rb

Instance Method Summary collapse

Instance Method Details

#bind_handler(method_name, method_proc) ⇒ Object



5
6
7
8
9
10
11
12
13
14
# File 'lib/rhoconnect/handler/helpers/binding.rb', line 5

def bind_handler(method_name, method_proc)
  # do nothing if already bound
  return method_proc if method_proc.is_a?Method

  self.class.send :define_method, method_name, method_proc
  method = self.class.instance_method(method_name)
  self.class.send :remove_method, method_name
  # bind it to self
  method.bind(self)
end