Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Instrumentation
- class Controller
- def dispatch
- puts :dispatched
- end
- end
- class OtherController < Controller
- end
- module Timing
- def dispatch
- start = Time.now
- super
- elapsed = Time.now - start
- puts "#{self.class}#dispatch took #{elapsed}s"
- end
- end
- module TimingExtension
- def new(*args, &block)
- super.extend(Timing)
- end
- end
- Controller.extend(TimingExtension)
- # Runtime
- Controller.new.dispatch
- OtherController.new.dispatch
Add Comment
Please, Sign In to add comment