Sha256: 76def9676b1051ec9f38b33c06d285fbfc4b563a89921f88f447c7f56bb5a2cc
Contents?: true
Size: 791 Bytes
Versions: 1
Compression:
Stored size: 791 Bytes
Contents
require_relative '../lib/method_observer' class Dummy def self.foo puts 'Running foo' end def bar puts 'Running bar' end end MethodObserver.configure do |config| config.before do |klass, target, method, *args| puts "Before: #{klass}#{target == :class ? '.' : '#'}#{method}" end config.after do |klass, target, method, *args| puts "After: #{klass}#{target == :class ? '.' : '#'}#{method}" puts end config.around do |klass, target, method, *args, &block| puts "Around before: #{klass}#{target == :class ? '.' : '#'}#{method}" block.call puts "Around after: #{klass}#{target == :class ? '.' : '#'}#{method}" end config.observe Dummy, class: [:foo], instance: [:bar] end Dummy.foo Dummy.name dummy = Dummy.new dummy.bar dummy.to_s
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
method_observer-0.0.1 | examples/puts.rb |