Created
May 19, 2019 20:21
-
-
Save yoones/089371584d90d022dae607e44bfc9daf to your computer and use it in GitHub Desktop.
initialize!
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
# Initialize the application passing the given group. By default, the | |
# group is :default | |
def initialize!(group = :default) #:nodoc: | |
raise "Application has been already initialized." if @initialized | |
run_initializers(group, self) | |
@initialized = true | |
self | |
end | |
def run_initializers(group = :default, *args) | |
return if instance_variable_defined?(:@ran) | |
initializers.tsort_each do |initializer| | |
initializer.run(*args) if initializer.belongs_to?(group) | |
end | |
@ran = true | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment