Module: Cardio::Logger::Performance::BigBrother
- Defined in:
- lib/cardio/logger/performance/big_brother.rb
Instance Method Summary collapse
- #logging_types(method_type) ⇒ Object
- #watch_all_instance_methods ⇒ Object
- #watch_all_methods ⇒ Object
- #watch_all_singleton_methods ⇒ Object
- #watch_instance_method(*names) ⇒ Object
- #watch_method(method_name, method_type = :all, options = {}) ⇒ Object
- #watch_singleton_method(*names) ⇒ Object
Instance Method Details
#logging_types(method_type) ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/cardio/logger/performance/big_brother.rb', line 14 def logging_types method_type if method_type == :all %i[singleton instance] else [method_type] end end |
#watch_all_instance_methods ⇒ Object
34 35 36 |
# File 'lib/cardio/logger/performance/big_brother.rb', line 34 def watch_all_instance_methods watch_instance_method *instance_methods end |
#watch_all_methods ⇒ Object
43 44 45 46 |
# File 'lib/cardio/logger/performance/big_brother.rb', line 43 def watch_all_methods watch_all_instance_methods watch_all_singleton_methods end |
#watch_all_singleton_methods ⇒ Object
38 39 40 41 |
# File 'lib/cardio/logger/performance/big_brother.rb', line 38 def watch_all_singleton_methods fragile_methods = [:default_scope, :default_scopes, :default_scopes=] # if I touch these methods ActiveRecord breaks watch_singleton_method *(singleton_methods - fragile_methods) end |
#watch_instance_method(*names) ⇒ Object
22 23 24 25 26 |
# File 'lib/cardio/logger/performance/big_brother.rb', line 22 def watch_instance_method *names names.each do |name| watch_method name, :instance end end |
#watch_method(method_name, method_type = :all, options = {}) ⇒ Object
5 6 7 8 9 10 11 12 |
# File 'lib/cardio/logger/performance/big_brother.rb', line 5 def watch_method method_name, method_type=:all, ={} Performance.enable_method method_name return if SPECIAL_METHODS.include? method_name logging_types(method_type).each do |logging_type| send "add_#{logging_type}_logging", method_name, end end |
#watch_singleton_method(*names) ⇒ Object
28 29 30 31 32 |
# File 'lib/cardio/logger/performance/big_brother.rb', line 28 def watch_singleton_method *names names.each do |name| watch_method name, :singleton end end |