Skip to content
This repository
Browse code

Cleaned up the class_eval stuff in the new mixins a bit

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@87 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
  • Loading branch information...
commit 3fef01649327243d6e811cef2be1707aa30eab62 1 parent fdd2859
David Heinemeier Hansson dhh authored
8 activerecord/lib/active_record/mixins/list.rb
@@ -28,11 +28,9 @@ module Mixins
28 28 # todo_list.last.move_higher
29 29 module List
30 30 def self.append_features(base)
31   - super
32   - base.class_eval do
33   - before_destroy :remove_from_list
34   - after_create :add_to_list_bottom
35   - end
  31 + super
  32 + base.before_destroy :remove_from_list
  33 + base.after_create :add_to_list_bottom
36 34 end
37 35
38 36 # Moving around on the list
9 activerecord/lib/active_record/mixins/touch.rb
@@ -17,12 +17,13 @@ module Mixins
17 17 module Touch
18 18 def self.append_features(base)
19 19 super
20   - base.class_eval do
21   - before_create :touch_on_create
22   - before_update :touch_on_update
23 20
  21 + base.before_create :touch_on_create
  22 + base.before_update :touch_on_update
  23 +
  24 + base.class_eval do
24 25 def touch_on_create
25   - self.created_at = self.updated_at = Time.now
  26 + self.updated_at = (self.created_at ||= Time.now)
26 27 end
27 28
28 29 def touch_on_update

0 comments on commit 3fef016

Please sign in to comment.
Something went wrong with that request. Please try again.