Changesets can be listed by changeset number.
The Git repository is here.
- Revision:
- 373
- Log:
Initial import of Radiant 0.9.1, which is now packaged as a gem. This is an
import of the tagged 0.9.1 source checked out from GitHub, which isn't quite
the same as the gem distribution - but it doesn't seem to be available in an
archived form and the installed gem already has modifications, so this is
the closest I can get.
- Author:
- rool
- Date:
- Mon Mar 21 13:40:05 +0000 2011
- Size:
- 2688 Bytes
1 | module ActiveRecord |
2 | # Active Record automatically timestamps create and update operations if the table has fields |
3 | # named created_at/created_on or updated_at/updated_on. |
4 | # |
5 | # Timestamping can be turned off by setting |
6 | # <tt>ActiveRecord::Base.record_timestamps = false</tt> |
7 | # |
8 | # Timestamps are in the local timezone by default but you can use UTC by setting |
9 | # <tt>ActiveRecord::Base.default_timezone = :utc</tt> |
10 | module Timestamp |
11 | def self.included(base) #:nodoc: |
12 | base.alias_method_chain :create, :timestamps |
13 | base.alias_method_chain :update, :timestamps |
14 | |
15 | base.class_inheritable_accessor :record_timestamps, :instance_writer => false |
16 | base.record_timestamps = true |
17 | end |
18 | |
19 | # Saves the record with the updated_at/on attributes set to the current time. |
20 | # If the save fails because of validation errors, an ActiveRecord::RecordInvalid exception is raised. |
21 | # If an attribute name is passed, that attribute is used for the touch instead of the updated_at/on attributes. |
22 | # |
23 | # Examples: |
24 | # |
25 | # product.touch # updates updated_at |
26 | # product.touch(:designed_at) # updates the designed_at attribute |
27 | def touch(attribute = nil) |
28 | current_time = current_time_from_proper_timezone |
29 | |
30 | if attribute |
31 | write_attribute(attribute, current_time) |
32 | else |
33 | write_attribute('updated_at', current_time) if respond_to?(:updated_at) |
34 | write_attribute('updated_on', current_time) if respond_to?(:updated_on) |
35 | end |
36 | |
37 | save! |
38 | end |
39 | |
40 | |
41 | private |
42 | def create_with_timestamps #:nodoc: |
43 | if record_timestamps |
44 | current_time = current_time_from_proper_timezone |
45 | |
46 | write_attribute('created_at', current_time) if respond_to?(:created_at) && created_at.nil? |
47 | write_attribute('created_on', current_time) if respond_to?(:created_on) && created_on.nil? |
48 | |
49 | write_attribute('updated_at', current_time) if respond_to?(:updated_at) && updated_at.nil? |
50 | write_attribute('updated_on', current_time) if respond_to?(:updated_on) && updated_on.nil? |
51 | end |
52 | |
53 | create_without_timestamps |
54 | end |
55 | |
56 | def update_with_timestamps(*args) #:nodoc: |
57 | if record_timestamps && (!partial_updates? || changed?) |
58 | current_time = current_time_from_proper_timezone |
59 | |
60 | write_attribute('updated_at', current_time) if respond_to?(:updated_at) |
61 | write_attribute('updated_on', current_time) if respond_to?(:updated_on) |
62 | end |
63 | |
64 | update_without_timestamps(*args) |
65 | end |
66 | |
67 | def current_time_from_proper_timezone |
68 | self.class.default_timezone == :utc ? Time.now.utc : Time.now |
69 | end |
70 | end |
71 | end |