Class: Merb::BootLoader
Direct Known Subclasses
AfterAppLoads, BackgroundServices, BeforeAppLoads, BuildFramework, ChooseAdapter, Cookies, Defaults, Dependencies, DropPidFile, LoadClasses, Logger, MimeTypes, MixinSession, RackUpApplication, ReloadClasses, Router, SetupSession, SetupStubClasses, Templates, Slices::Activate, Slices::Initialize, Slices::Loader
Defined Under Namespace
Classes: AfterAppLoads, BackgroundServices, BeforeAppLoads, BuildFramework, ChooseAdapter, Cookies, Defaults, Dependencies, DropPidFile, LoadClasses, Logger, MimeTypes, MixinSession, RackUpApplication, ReloadClasses, Router, SetupSession, SetupStubClasses, Templates
Class Method Summary (collapse)
-
+ (nil) after(klass)
Execute this boot loader after the specified boot loader.
-
+ (Object) after_app_loads(&block)
Execute a block of code after the app loads.
-
+ (nil) before(klass)
Execute this boot loader before the specified boot loader.
-
+ (Object) before_app_loads(&block)
Execute a block of code before the app loads but after dependencies load.
-
+ (Object) before_master_shutdown(&block)
Execute a block of code before master process is shut down.
-
+ (Object) before_worker_shutdown(&block)
Execute a block of code before worker process is shut down.
-
+ (nil) default_framework
Set up the default framework.
-
+ (Boolean) finished?(bootloader)
private
Determines whether or not a specific bootloader has finished yet.
-
+ (nil) inherited(klass)
Adds the inheriting class to the list of subclasses in a position specified by the before and after methods.
-
+ (nil) move_klass(klass, where)
private
Move a class that is inside the bootloader to some place in the Array, relative to another class.
-
+ (nil) run
Runs all boot loader classes by calling their run methods.
Class Method Details
+ (nil) after(klass)
Execute this boot loader after the specified boot loader.
38 39 40 41 |
# File 'merb-core/lib/merb-core/bootloader.rb', line 38 def after(klass) move_klass(klass, 1) nil end |
+ (Object) after_app_loads(&block)
Execute a block of code after the app loads.
134 135 136 |
# File 'merb-core/lib/merb-core/bootloader.rb', line 134 def after_app_loads(&block) after_load_callbacks << block end |
+ (nil) before(klass)
Execute this boot loader before the specified boot loader.
51 52 53 54 |
# File 'merb-core/lib/merb-core/bootloader.rb', line 51 def before(klass) move_klass(klass, 0) nil end |
+ (Object) before_app_loads(&block)
Execute a block of code before the app loads but after dependencies load.
144 145 146 |
# File 'merb-core/lib/merb-core/bootloader.rb', line 144 def before_app_loads(&block) before_load_callbacks << block end |
+ (Object) before_master_shutdown(&block)
Execute a block of code before master process is shut down. Only makes sense on platforms where Merb server can use forking.
155 156 157 |
# File 'merb-core/lib/merb-core/bootloader.rb', line 155 def before_master_shutdown(&block) before_master_shutdown_callbacks << block end |
+ (Object) before_worker_shutdown(&block)
Execute a block of code before worker process is shut down. Only makes sense on platforms where Merb server can use forking.
166 167 168 |
# File 'merb-core/lib/merb-core/bootloader.rb', line 166 def before_worker_shutdown(&block) before_worker_shutdown_callbacks << block end |
+ (nil) default_framework
Set up the default framework
111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 |
# File 'merb-core/lib/merb-core/bootloader.rb', line 111 def default_framework %w[view model helper controller mailer part].each do |component| Merb.push_path(component.to_sym, Merb.root("app", component.pluralize)) end Merb.push_path :application, Merb.root("app", "controllers"), "application.rb" Merb.push_path :config, Merb.root("config"), nil Merb.push_path :router, Merb.dir_for(:config), (Merb::Config[:router_file] || "router.rb") Merb.push_path :lib, Merb.root("lib"), nil Merb.push_path :merb_session, Merb.root("merb" / "session") Merb.push_path :log, Merb.log_path, nil Merb.push_path :public, Merb.root("public"), nil Merb.push_path :stylesheet, Merb.dir_for(:public) / "stylesheets", nil Merb.push_path :javascript, Merb.dir_for(:public) / "javascripts", nil Merb.push_path :image, Merb.dir_for(:public) / "images", nil nil end |
+ (Boolean) finished?(bootloader)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Determines whether or not a specific bootloader has finished yet.
101 102 103 |
# File 'merb-core/lib/merb-core/bootloader.rb', line 101 def finished?(bootloader) self.finished.include?(bootloader.to_s) end |
+ (nil) inherited(klass)
Adds the inheriting class to the list of subclasses in a position specified by the before and after methods.
25 26 27 28 |
# File 'merb-core/lib/merb-core/bootloader.rb', line 25 def inherited(klass) subclasses << klass.to_s super end |
+ (nil) move_klass(klass, where)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Move a class that is inside the bootloader to some place in the Array, relative to another class.
65 66 67 68 69 70 71 72 |
# File 'merb-core/lib/merb-core/bootloader.rb', line 65 def move_klass(klass, where) index = Merb::BootLoader.subclasses.index(klass.to_s) if index Merb::BootLoader.subclasses.delete(self.to_s) Merb::BootLoader.subclasses.insert(index + where, self.to_s) end nil end |
+ (nil) run
Runs all boot loader classes by calling their run methods.
79 80 81 82 83 84 85 86 87 88 89 90 91 92 |
# File 'merb-core/lib/merb-core/bootloader.rb', line 79 def run Merb.started = true subklasses = subclasses.dup until subclasses.empty? time = Time.now.to_i bootloader = subclasses.shift Merb.logger.debug!("Loading: #{bootloader}") if Merb.verbose_logging? Object.full_const_get(bootloader).run Merb.logger.debug!("It took: #{Time.now.to_i - time}") if Merb.verbose_logging? self.finished << bootloader end self.subclasses = subklasses nil end |