Class: Merb::BootLoader
Direct Known Subclasses
AfterAppLoads, BeforeAppRuns, BuildFramework, ChooseAdapter, Dependencies, DropPidFile, LoadClasses, Logger, MimeTypes, MixinSessionContainer, RackUpApplication, ReloadClasses, ReloadTemplates, Templates
Defined Under Namespace
Classes: AfterAppLoads, BeforeAppRuns, BuildFramework, ChooseAdapter, Dependencies, DropPidFile, LoadClasses, Logger, MimeTypes, MixinSessionContainer, RackUpApplication, ReloadClasses, ReloadTemplates, Templates
Class Method Summary collapse
-
.after(klass) ⇒ Object
Parameters klass<~to_s>:: The boot loader class after which this boot loader should be run.
-
.after_app_loads(&block) ⇒ Object
Parameters &block:: A block to be added to the callbacks that will be executed after the app loads.
-
.before(klass) ⇒ Object
Parameters klass<~to_s>:: The boot loader class before which this boot loader should be run.
-
.before_app_loads(&block) ⇒ Object
Parameters &block:: A block to be added to the callbacks that will be executed before the app loads.
-
.default_framework ⇒ Object
Set up the default framework.
-
.inherited(klass) ⇒ Object
Adds the inheriting class to the list of subclasses in a position specified by the before and after methods.
-
.move_klass(klass, where) ⇒ Object
Move a class that is inside the bootloader to some place in the Array, relative to another class.
-
.run ⇒ Object
Runs all boot loader classes by calling their run methods.
Class Method Details
.after(klass) ⇒ Object
Parameters
- klass<~to_s>
-
The boot loader class after which this boot loader should be run.
31 32 33 |
# File 'lib/merb-core/bootloader.rb', line 31 def after(klass) move_klass(klass, 1) end |
.after_app_loads(&block) ⇒ Object
Parameters
- &block
-
A block to be added to the callbacks that will be executed after the app loads.
102 103 104 |
# File 'lib/merb-core/bootloader.rb', line 102 def after_app_loads(&block) after_load_callbacks << block end |
.before(klass) ⇒ Object
Parameters
- klass<~to_s>
-
The boot loader class before which this boot loader should be run.
41 42 43 |
# File 'lib/merb-core/bootloader.rb', line 41 def before(klass) move_klass(klass, 0) end |
.before_app_loads(&block) ⇒ Object
Parameters
- &block
-
A block to be added to the callbacks that will be executed before the app loads.
113 114 115 |
# File 'lib/merb-core/bootloader.rb', line 113 def before_app_loads(&block) before_load_callbacks << block end |
.default_framework ⇒ Object
Set up the default framework
Returns
nil
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/merb-core/bootloader.rb', line 79 def default_framework %w[view model controller helper mailer part].each do |component| Merb.push_path(component.to_sym, Merb.root_path("app/#{component}s")) end Merb.push_path(:application, Merb.root_path("app/controllers/application.rb")) Merb.push_path(:config, Merb.root_path("config"), nil) Merb.push_path(:router, Merb.dir_for(:config), (Merb::Config[:router_file] || "router.rb")) Merb.push_path(:lib, Merb.root_path("lib"), nil) Merb.push_path(:log, Merb.log_path, nil) Merb.push_path(:public, Merb.root_path("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 |
.inherited(klass) ⇒ Object
Adds the inheriting class to the list of subclasses in a position specified by the before and after methods.
Parameters
- klass<Class>
-
The class inheriting from Merb::BootLoader.
20 21 22 23 |
# File 'lib/merb-core/bootloader.rb', line 20 def inherited(klass) subclasses << klass.to_s super end |
.move_klass(klass, where) ⇒ Object
Move a class that is inside the bootloader to some place in the Array, relative to another class.
Parameters
- klass<~to_s>
-
The klass to move the bootloader relative to
- where<Integer>
-
0 means insert it before; 1 means insert it after
53 54 55 56 57 58 59 |
# File 'lib/merb-core/bootloader.rb', line 53 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 end |
.run ⇒ Object
Runs all boot loader classes by calling their run methods.
62 63 64 65 66 67 68 69 70 |
# File 'lib/merb-core/bootloader.rb', line 62 def run subklasses = subclasses.dup until subclasses.empty? bootloader = subclasses.shift Merb.logger.debug!("Loading: #{bootloader}") if ENV['DEBUG'] Object.full_const_get(bootloader).run end self.subclasses = subklasses end |