Module: ExecutionDeadline::MethodProxy
- Defined in:
- lib/execution_deadline/method_proxy.rb
Class Method Summary collapse
- .construct_for_class(klass) ⇒ Object
- .find_for_class(klass) ⇒ Object
- .for_class(klass) ⇒ Object
- .install_on_class(klass) ⇒ Object
Class Method Details
.construct_for_class(klass) ⇒ Object
22 23 24 25 26 |
# File 'lib/execution_deadline/method_proxy.rb', line 22 def self.construct_for_class(klass) Module.new do extend Deadliner end.tap { |m| m._execution_deadline_built_for = klass } end |
.find_for_class(klass) ⇒ Object
9 10 11 12 13 14 |
# File 'lib/execution_deadline/method_proxy.rb', line 9 def self.find_for_class(klass) klass.ancestors.detect do |a| a.is_a?(Deadliner) && a._execution_deadline_built_for == klass end end |
.for_class(klass) ⇒ Object
5 6 7 |
# File 'lib/execution_deadline/method_proxy.rb', line 5 def self.for_class(klass) find_for_class(klass) || install_on_class(klass) end |
.install_on_class(klass) ⇒ Object
16 17 18 19 20 |
# File 'lib/execution_deadline/method_proxy.rb', line 16 def self.install_on_class(klass) construct_for_class(klass).tap do |m| klass.prepend(m) end end |