Class: Class
- Inherits:
-
Object
- Object
- Class
- Defined in:
- lib/qmin/core_ext/class.rb
Overview
Extends class with #background(method_name) The annotated method will be handled by Qmin and it’s current strategy
Instance Method Summary collapse
-
#background(*method_names) ⇒ Object
Define one or many methods that you want to be handled by Qmin’s #background_call method.
- #define_qmin_background_method(method_name) ⇒ Object
Instance Method Details
#background(*method_names) ⇒ Object
Define one or many methods that you want to be handled by Qmin’s #background_call method. Calls to these methods will be handled by the configured Qmin::Strategy#background_call method The original methods are still available through “<method_name>_without_qmin”
8 9 10 11 12 |
# File 'lib/qmin/core_ext/class.rb', line 8 def background(*method_names) method_names.each do |method_name| define_qmin_background_method method_name.to_s end end |
#define_qmin_background_method(method_name) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/qmin/core_ext/class.rb', line 14 def define_qmin_background_method(method_name) return if respond_to?("#{method_name}_without_qmin") || !!method_name.match(/_without_qmin$/) alias_method "#{method_name}_without_qmin", method_name.to_sym define_method method_name do ::Qmin::Qmin.background_call(self, method_name.to_sym) end end |