Skip to content

Instantly share code, notes, and snippets.

@yoones
Created May 19, 2019 20:21
Show Gist options
  • Save yoones/089371584d90d022dae607e44bfc9daf to your computer and use it in GitHub Desktop.
Save yoones/089371584d90d022dae607e44bfc9daf to your computer and use it in GitHub Desktop.
initialize!
# 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