From 0095f24af760fd2795745b31c2df64b7bb47c7ec Mon Sep 17 00:00:00 2001 From: Martin Edenhofer Date: Fri, 1 Feb 2013 18:43:37 +0100 Subject: [PATCH] Added reload of classes after a package got installed. --- app/models/package.rb | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/app/models/package.rb b/app/models/package.rb index 8b67d4d79..1257c1dcd 100644 --- a/app/models/package.rb +++ b/app/models/package.rb @@ -208,6 +208,9 @@ class Package < ApplicationModel record.state = 'installed' record.save + # reload new files + Package.reload_classes + # up migrations Package::Migration.migrate( meta[:name] ) @@ -258,6 +261,17 @@ class Package < ApplicationModel return true end + # reload .rb files in case they have changed + def self.reload_classes + ['app', 'lib'].each {|dir| + Dir.glob( Rails.root.join( dir + '/**/*') ).each {|entry| + if entry =~ /\.rb$/ + load entry + end + } + } + end + def self._parse(xml) # puts xml.inspect begin @@ -420,6 +434,9 @@ class Package < ApplicationModel Kernel.const_get(classname).up Package::Migration.create( :name => package.underscore, :version => version ) end + + # reload new files + Package.reload_classes } end end