lib/grape/reload/watcher.rb in grape-reload-0.0.3 vs lib/grape/reload/watcher.rb in grape-reload-0.0.4
- old
+ new
@@ -15,11 +15,11 @@
def safe_load(file, options={})
return unless options[:force] || file_changed?(file)
Storage.prepare(file) # might call #safe_load recursively
- logger.debug((file_new?(file) ? "loading" : "reloading") + "#{file}" )
+ logger.debug((file_new?(file) ? "loading" : "reloading") + " #{file}" )
begin
with_silence{ require(file) }
Storage.commit(file)
update_modification_time(file)
rescue Exception => exception
@@ -100,12 +100,11 @@
changed_files_sorted = @sources.sorted_files.select{|f| files[:changed].include?(f)}
@sources.files_reloading do
changed_files_sorted.each{|f| safe_load(f)}
end
changed_files_sorted.map{|f| @sources.dependent_classes(f) }.flatten.uniq.each {|class_name|
- if (klass = class_name.constantize) < Grape::API
- klass.reinit!
- end
+ next unless (klass = class_name.constantize).kind_of? Class
+ klass.reinit! if klass.respond_to?('reinit!')
}
end
##
# Removes the specified class and constant.
\ No newline at end of file