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.
This commit is contained in:
Sam 2015-02-12 14:44:40 +11:00
parent 3c6aede1aa
commit ab3d4471fe

View file

@ -394,7 +394,7 @@ module SiteSettingExtension
def setup_methods(name) def setup_methods(name)
clean_name = name.to_s.sub("?", "") clean_name = name.to_s.sub("?", "")
eval "define_singleton_method :#{clean_name} do define_singleton_method clean_name do
c = @containers[provider.current_site] c = @containers[provider.current_site]
if c if c
c[name] c[name]
@ -404,14 +404,13 @@ module SiteSettingExtension
end end
end end
define_singleton_method :#{clean_name}? do define_singleton_method clean_name + "?" do
#{clean_name} clean_name
end end
define_singleton_method :#{clean_name}= do |val| define_singleton_method clean_name + "=" do |val|
add_override!(:#{name}, val) add_override!(name, val)
end end
"
end end
def enum_class(name) def enum_class(name)