Module: Bubot

Defined in:
lib/bubot.rb,
lib/bubot/version.rb

Constant Summary collapse

VERSION =
"0.0.1"

Instance Method Summary collapse

Instance Method Details

#watch(method_name, timeout, &block) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
# File 'lib/bubot.rb', line 5

def watch(method_name, timeout, &block)
  define_method("#{method_name}_with_feature") do
    start_time = Time.now
    response = send("#{method_name}_without_feature".to_sym)
    if (Time.now - start_time) > timeout
      block.call(self)
    end
    response
  end

  alias_method_chain_or_register(method_name)
end