Created
May 21, 2010 04:04
-
-
Save atoulme/408446 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# find first callback with satisfied dependencies | |
def first_satisfied(r, known_callbacks) | |
remaining_names = r.map { |cb| cb.name } | |
res = r.find do |cb| | |
cb.dependencies.each do |dep| | |
fail "Unknown #{phase.inspect} extension dependency: #{dep.inspect}" unless known_callbacks.index(dep) | |
end | |
satisfied = cb.dependencies.find { |dep| remaining_names.index(dep) } == nil | |
cb if satisfied | |
end | |
r.delete res | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment