Skip to content

Instantly share code, notes, and snippets.

@jhtwong
Created June 16, 2011 18:41
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jhtwong/1029924 to your computer and use it in GitHub Desktop.
Save jhtwong/1029924 to your computer and use it in GitHub Desktop.
Rails::Application::Railties#all
def all(&block)
@railties_plus_engines ||= railties + engines
@railties_plus_engines.each(&block) if block
# Only after the block has been run against the railties and engines in the application
# will we call super with the block (which has the effect of running the block against the plugins in the
# application and returning the array of plugins)
@railties_plus_engines + super(&block)
end
@josevalim
Copy link

What about this:

def all(&block)
  # Pass a block to super so it doesn't pass the current one
  @all ||= railties + engines + super { |x| x }
  @all.each(&block) if block
  @all
end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment