mirror of
https://github.com/ditkrg/validates_timeliness.git
synced 2026-01-22 22:06:45 +00:00
Generate attribute methods once instead of on each object creation
This is a memory and performance improvement change. The attribute methods for timeliness are generated at each object creation instead of once, at first creation like AR attribute methods. Since creating those methods uses `module_eval` it's quite slow when it's done each `Model.new`. For more details on the performance improvement, see the same change on John Carney's fork: https://github.com/johncarney/validates_timeliness/pull/6
This commit is contained in:
parent
12f6d2a467
commit
7d37882327
@ -23,7 +23,9 @@ module ValidatesTimeliness
|
||||
|
||||
def define_attribute_methods
|
||||
super.tap do |attribute_methods_generated|
|
||||
return false if @timeliness_methods_generated
|
||||
define_timeliness_methods true
|
||||
@timeliness_methods_generated = true
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user