Created
June 7, 2021 17:45
-
-
Save ogryzek/9f16c5d81dc6fe0cd46fa95083c58c55 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
require 'sinatra' | |
# require and use controllers from within the `./controller` directory | |
controller_paths = Dir["./controllers/*.rb"].each { |file| require_relative file } | |
controllers = controller_paths.map { |controller_path| controller_path[/controllers\/(.*?)_controller/m, 1] } | |
controllers.each { |controller| use Object.const_get("#{controller.capitalize}Controller") } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment