Skip to content

Instantly share code, notes, and snippets.

@seancdavis
Created June 24, 2017 12:48
Show Gist options
  • Save seancdavis/142039a58f8ac8468f1aa2370e8af502 to your computer and use it in GitHub Desktop.
Save seancdavis/142039a58f8ac8468f1aa2370e8af502 to your computer and use it in GitHub Desktop.
Load all modules within a namespaced directory
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