From ab3d4471fedc3fac661c69c1588400dc908043dc Mon Sep 17 00:00:00 2001 From: Sam Date: Thu, 12 Feb 2015 14:44:40 +1100 Subject: [PATCH] PERF: remove eval cause it is costing lots of memory see: http://tenderlovemaking.com/2013/03/03/dynamic_method_definitions.html isolated via memory profiler gem. --- lib/site_setting_extension.rb | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/site_setting_extension.rb b/lib/site_setting_extension.rb index d700a528712..44e47693d97 100644 --- a/lib/site_setting_extension.rb +++ b/lib/site_setting_extension.rb @@ -394,7 +394,7 @@ module SiteSettingExtension def setup_methods(name) clean_name = name.to_s.sub("?", "") - eval "define_singleton_method :#{clean_name} do + define_singleton_method clean_name do c = @containers[provider.current_site] if c c[name] @@ -404,14 +404,13 @@ module SiteSettingExtension end end - define_singleton_method :#{clean_name}? do - #{clean_name} + define_singleton_method clean_name + "?" do + clean_name end - define_singleton_method :#{clean_name}= do |val| - add_override!(:#{name}, val) + define_singleton_method clean_name + "=" do |val| + add_override!(name, val) end - " end def enum_class(name)