Created
June 24, 2017 12:48
-
-
Save seancdavis/142039a58f8ac8468f1aa2370e8af502 to your computer and use it in GitHub Desktop.
Load all modules within a namespaced directory
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
module Utils::All | |
# I wrote this originally for model concerns, in which case I needed | |
# the following line to be included: | |
# extend ActiveSupport::Concern | |
Dir.glob(File.expand_path('../', __FILE__) + '/*.rb').each do |util| | |
next if File.basename(util) == 'base.rb' | |
include "Utils::#{File.basename(util, '.rb').camelize}".constantize | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment