Module: One9::Spy
- Defined in:
- lib/one9/spy.rb
Class Method Summary collapse
Class Method Details
.eval_string(meth) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/one9/spy.rb', line 25 def self.eval_string(meth) alias_code = "alias_method :'_one9_#{meth.meth}', :'#{meth.meth}'" alias_code = "class <<self; #{alias_code}; end" if meth.class_method? %[#{alias_code} def #{meth.meth}(*args, &block) One9.spy('#{meth.name}') send(:'_one9_#{meth.meth}', *args, &block) end ] end |
.setup(methods) ⇒ Object
3 4 5 6 7 8 9 |
# File 'lib/one9/spy.rb', line 3 def self.setup(methods) valid_methods(methods).each do |meth| str = eval_string(meth) eval_meth = meth.class_method? ? :instance_eval : :module_eval meth.real_klass.send(eval_meth, str) end end |
.valid_methods(methods) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/one9/spy.rb', line 11 def self.valid_methods(methods) methods.select do |meth| if meth.real_klass.nil? puts "#{meth.klass} does not exist. Skipping #{meth.name}..." false elsif !meth.exists? puts "#{meth.name} is not a method. Skipping ..." false else true end end end |