lib/service_manager.rb in service_manager-0.5 vs lib/service_manager.rb in service_manager-0.6

- old
+ new

@@ -7,19 +7,24 @@ extend self def services return @services if @services - @services = [] - load_services - @services + + (@services = []).tap do + load_services if service_files_loaded.empty? + end end + def service_files_loaded + @service_files_loaded ||= [] + end + def load_services(path = nil) - path ||= SERVICES_PATH - return if @services_loaded + path = File.expand_path(path || SERVICES_PATH, Dir.pwd) + return if service_files_loaded.include?(path) + service_files_loaded << path load path - @services_loaded = true end def define_service(name = nil, &block) name ||= File.basename(caller.first.gsub(/.rb:.+$/, "")) ServiceManager::Service.new(:name => name).tap do |service|