Created
March 17, 2009 06:48
-
-
Save deepthawtz/80358 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 | |
def after(klass) | |
move_klass(klass, 1) | |
nil | |
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 | |
def before(klass) | |
move_klass(klass, 0) | |
nil | |
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 | |
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment