Module: Rubikon::Application::ClassMethods
- Included in:
- Base
- Defined in:
- lib/rubikon/application/class_methods.rb
Overview
This module contains all class methods of Application::Base
and its subclasses.
Instance Method Summary collapse
-
#autorun? ⇒ Boolean
private
Returns whether this application should be run automatically.
-
#inherited(subclass) ⇒ Object
private
Enables autorun functionality using
Kernel#at_exit
. -
#method_missing(method_name, *args, &block) ⇒ Object
private
This is used for convinience.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object (private)
This is used for convinience. Method calls on the class itself are relayed to the singleton instance.
This is called automatically when calling methods on the application class.
53 54 55 |
# File 'lib/rubikon/application/class_methods.rb', line 53 def method_missing(method_name, *args, &block) instance.send(method_name, *args, &block) end |
Instance Method Details
#autorun? ⇒ Boolean (private)
Returns whether this application should be run automatically
23 24 25 |
# File 'lib/rubikon/application/class_methods.rb', line 23 def autorun? instance.instance_variable_get(:@settings)[:autorun] || false end |
#inherited(subclass) ⇒ Object (private)
Enables autorun functionality using Kernel#at_exit
This is called automatically when subclassing Application::Base.
34 35 36 37 38 39 40 41 42 |
# File 'lib/rubikon/application/class_methods.rb', line 34 def inherited(subclass) subclass.class_eval { include Singleton } subclass.send(:base_file=, File.(caller.first.split(':').first)) at_exit do if subclass.send(:autorun?) InstanceMethods.instance_method(:run).bind(subclass.instance).call end end end |