Improve Rails4 performance by 20%, before the median on the page is 53ms, after it is 44ms

This commit is contained in:
Sam 2013-09-03 17:39:56 +10:00
parent f13a408c2a
commit 46d5314ec4
1 changed files with 9 additions and 12 deletions

View File

@ -231,30 +231,27 @@ module SiteSettingExtension
# trivial multi db support, we can optimize this later
current[name] = current_value
clean_name = name.to_s.sub("?", "")
setter = ("#{name}=").sub("?","")
eval "define_singleton_method :#{name} do
eval "define_singleton_method :#{clean_name} do
c = @@containers[provider.current_site]
c = c[name] if c
c
end
define_singleton_method :#{setter} do |val|
define_singleton_method :#{clean_name}? do
c = @@containers[provider.current_site]
c = c[name] if c
c
end
define_singleton_method :#{clean_name}= do |val|
add_override!(:#{name}, val)
refresh!
end
"
end
def method_missing(method, *args, &block)
as_question = method.to_s.gsub(/\?$/, '')
if respond_to?(as_question)
return send(as_question, *args, &block)
end
super(method, *args, &block)
end
def enum_class(name)
enums[name]
end