Skip to content

Commit

Permalink
Respect inflections defined by ActiveSupport when autoloading
Browse files Browse the repository at this point in the history
ActiveSupport's own autoloading feature respects these so it is less
surprising if require_all does the same.
  • Loading branch information
chewi committed Jun 20, 2018
1 parent 7acaa63 commit e228014
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion lib/require_all.rb
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,13 @@ def __autoload(file, full_path, options)
mod = Object.class_eval(last_module)

without_ext = entry.basename(entry.extname).to_s
const = without_ext.split("_").map {|word| word.capitalize}.join

const =
if defined? ActiveSupport::Inflector
ActiveSupport::Inflector.camelize(without_ext)
else
without_ext.split("_").map {|word| word.capitalize}.join
end

if entry.file? || (entry.directory? && entry.sub_ext('.rb').file?)
mod.class_eval do
Expand Down

0 comments on commit e228014

Please sign in to comment.