lib/rails_imager.rb in rails_imager-0.0.18 vs lib/rails_imager.rb in rails_imager-0.0.19

- old
+ new

@@ -1,19 +1,25 @@ require "rails/engine" require "rails_imager/engine" require "string-cases" +require "datet" +require "knjrbfw" +require "RMagick" unless ::Kernel.const_defined?(:RMagick) module RailsImager def self.const_missing(name) if name.to_s.end_with?("Controller") - path = "#{File.dirname(__FILE__)}/../app/controllers/rails_imager/#{::StringCases.camel_to_snake(name)}" + path = "#{File.dirname(__FILE__)}/../app/controllers/rails_imager/#{::StringCases.camel_to_snake(name)}.rb" elsif name.to_s.end_with?("Helper") - path = "#{File.dirname(__FILE__)}/../app/helpers/rails_imager/#{::StringCases.camel_to_snake(name)}" + path = "#{File.dirname(__FILE__)}/../app/helpers/rails_imager/#{::StringCases.camel_to_snake(name)}.rb" else - path = "#{File.dirname(__FILE__)}/rails_imager/#{::StringCases.camel_to_snake(name)}" + path = "#{File.dirname(__FILE__)}/rails_imager/#{::StringCases.camel_to_snake(name)}.rb" end - require path - raise LoadError, "Not autoloaded: #{name}" unless const_defined?(name) - return const_get(name) + if File.exists?(path) + require path + return const_get(name) if const_defined?(name) + end + + super end end