Class Merb::BootLoader
In: merb-core/lib/merb-core/bootloader.rb
Parent: Object

Methods

Classes and Modules

Class Merb::BootLoader::AfterAppLoads
Class Merb::BootLoader::BeforeAppLoads
Class Merb::BootLoader::BuildFramework
Class Merb::BootLoader::ChooseAdapter
Class Merb::BootLoader::Cookies
Class Merb::BootLoader::Defaults
Class Merb::BootLoader::Dependencies
Class Merb::BootLoader::DropPidFile
Class Merb::BootLoader::LoadClasses
Class Merb::BootLoader::Logger
Class Merb::BootLoader::MimeTypes
Class Merb::BootLoader::MixinSession
Class Merb::BootLoader::RackUpApplication
Class Merb::BootLoader::ReloadClasses
Class Merb::BootLoader::Router
Class Merb::BootLoader::SetupSession
Class Merb::BootLoader::SetupStubClasses
Class Merb::BootLoader::Templates

Public Class methods

Execute this boot loader after the specified boot loader.

Parameters

klass<~to_s>:The boot loader class after which this boot loader should be run.

Returns

nil

:api: plugin

[Source]

    # File merb-core/lib/merb-core/bootloader.rb, line 42
42:       def after(klass)
43:         move_klass(klass, 1)
44:         nil
45:       end

Execute a block of code after the app loads.

Parameters

&block:A block to be added to the callbacks that will be executed after the app loads.

:api: public

[Source]

     # File merb-core/lib/merb-core/bootloader.rb, line 154
154:       def after_app_loads(&block)
155:         after_load_callbacks << block
156:       end

Execute this boot loader before the specified boot loader.

Parameters

klass<~to_s>:The boot loader class before which this boot loader should be run.

Returns

nil

:api: plugin

[Source]

    # File merb-core/lib/merb-core/bootloader.rb, line 57
57:       def before(klass)
58:         move_klass(klass, 0)
59:         nil
60:       end

Execute a block of code before the app loads but after dependencies load.

Parameters

&block:A block to be added to the callbacks that will be executed before the app loads.

:api: public

[Source]

     # File merb-core/lib/merb-core/bootloader.rb, line 166
166:       def before_app_loads(&block)
167:         before_load_callbacks << block
168:       end

Execute a block of code before master process is shut down. Only makes sense on platforms where Merb server can use forking.

Parameters

&block:A block to be added to the callbacks that will be executed before master process is shut down.

:api: public

[Source]

     # File merb-core/lib/merb-core/bootloader.rb, line 179
179:       def before_master_shutdown(&block)
180:         before_master_shutdown_callbacks << block
181:       end

Execute a block of code before worker process is shut down. Only makes sense on platforms where Merb server can use forking.

Parameters

&block:A block to be added to the callbacks that will be executed before worker process is shut down.

:api: public

[Source]

     # File merb-core/lib/merb-core/bootloader.rb, line 192
192:       def before_worker_shutdown(&block)
193:         before_worker_shutdown_callbacks << block
194:       end

Set up the default framework

Returns

nil

:api: plugin @overridable

[Source]

     # File merb-core/lib/merb-core/bootloader.rb, line 129
129:       def default_framework
130:         %w[view model helper controller mailer part].each do |component|
131:           Merb.push_path(component.to_sym, Merb.root_path("app/#{component}s"))
132:         end
133:         Merb.push_path(:application,  Merb.root_path("app" / "controllers" / "application.rb"))
134:         Merb.push_path(:config,       Merb.root_path("config"), nil)
135:         Merb.push_path(:router,       Merb.dir_for(:config), (Merb::Config[:router_file] || "router.rb"))
136:         Merb.push_path(:lib,          Merb.root_path("lib"), nil)
137:         Merb.push_path(:merb_session, Merb.root_path("merb" / "session"))
138:         Merb.push_path(:log,          Merb.log_path, nil)
139:         Merb.push_path(:public,       Merb.root_path("public"), nil)
140:         Merb.push_path(:stylesheet,   Merb.dir_for(:public) / "stylesheets", nil)
141:         Merb.push_path(:javascript,   Merb.dir_for(:public) / "javascripts", nil)
142:         Merb.push_path(:image,        Merb.dir_for(:public) / "images", nil)
143:         nil
144:       end

Determines whether or not a specific bootloader has finished yet.

Parameters

bootloader<String, Class>:The name of the bootloader to check.

Returns

Boolean:Whether or not the bootloader has finished.

:api: private

[Source]

     # File merb-core/lib/merb-core/bootloader.rb, line 118
118:       def finished?(bootloader)
119:         self.finished.include?(bootloader.to_s)
120:       end

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.

Returns

nil

:api: plugin

[Source]

    # File merb-core/lib/merb-core/bootloader.rb, line 27
27:       def inherited(klass)
28:         subclasses << klass.to_s
29:         super
30:       end

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

Returns

nil

:api: private

[Source]

    # File merb-core/lib/merb-core/bootloader.rb, line 75
75:       def move_klass(klass, where)
76:         index = Merb::BootLoader.subclasses.index(klass.to_s)
77:         if index
78:           Merb::BootLoader.subclasses.delete(self.to_s)
79:           Merb::BootLoader.subclasses.insert(index + where, self.to_s)
80:         end
81:         nil
82:       end

Runs all boot loader classes by calling their run methods.

Returns

nil

:api: plugin

[Source]

     # File merb-core/lib/merb-core/bootloader.rb, line 90
 90:       def run
 91:         Merb.started = true
 92:         subklasses = subclasses.dup
 93:         until subclasses.empty?
 94:           time = Time.now.to_i
 95:           bootloader = subclasses.shift
 96:           if (ENV['DEBUG'] || $DEBUG || Merb::Config[:verbose]) && Merb.logger
 97:             Merb.logger.debug!("Loading: #{bootloader}")
 98:           end
 99:           Object.full_const_get(bootloader).run
100:           if (ENV['DEBUG'] || $DEBUG || Merb::Config[:verbose]) && Merb.logger
101:             Merb.logger.debug!("It took: #{Time.now.to_i - time}")
102:           end
103:           self.finished << bootloader
104:         end
105:         self.subclasses = subklasses
106:         nil
107:       end

[Validate]