seamusabshere-has_timestamps 1.5.0 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README +52 -0
- data/VERSION.yml +2 -2
- data/{lib → examples}/timestamp.rb +0 -0
- data/lib/has_timestamps.rb +1 -1
- metadata +10 -10
data/README
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
HasTimestamps
|
2
|
+
=================
|
3
|
+
|
4
|
+
Lets you timestamp models without adding a lot of timestamp fields to your tables.
|
5
|
+
|
6
|
+
Note: it **doesn't** save objects automatically, so you have to run a "user.save" (etc.) when you're done timestamping.
|
7
|
+
|
8
|
+
Installation
|
9
|
+
============
|
10
|
+
|
11
|
+
You should be able to run this as a plugin or as a gem.
|
12
|
+
|
13
|
+
For environment.rb:
|
14
|
+
|
15
|
+
config.gem 'seamusabshere-has_timestamps', :lib => 'has_timestamps', :source => 'http://gems.github.com'
|
16
|
+
|
17
|
+
Then be sure to:
|
18
|
+
|
19
|
+
sudo rake gems:install
|
20
|
+
|
21
|
+
Finally in a migration:
|
22
|
+
|
23
|
+
Timestamp.create_table (and Timestamp.drop_table for the down migration)
|
24
|
+
|
25
|
+
Example
|
26
|
+
=======
|
27
|
+
|
28
|
+
class User < ActiveRecord::Base
|
29
|
+
has_timestamps
|
30
|
+
end
|
31
|
+
|
32
|
+
>> user.timestamps
|
33
|
+
=> []
|
34
|
+
>> user.timestamp(:greeted)
|
35
|
+
=> Wed Dec 10 15:11:52 -0500 2008
|
36
|
+
>> user.timestamps
|
37
|
+
=> [#<Timestamp id: nil, timestampable_id: 14, timestampable_type: "User", key: "greeted", stamped_at: "2008-12-10 15:11:52", created_at: nil, updated_at: nil>]
|
38
|
+
>> user.save
|
39
|
+
=> true
|
40
|
+
>> user.timestamped?(:greeted)
|
41
|
+
=> true
|
42
|
+
>> user.timestamps[:greeted]
|
43
|
+
=> Wed Dec 10 15:11:52 -0500 2008
|
44
|
+
>> user.timestamped?(:saluted)
|
45
|
+
=> false
|
46
|
+
|
47
|
+
Credits
|
48
|
+
=======
|
49
|
+
|
50
|
+
Thanks to Fingertips for inspiration.
|
51
|
+
|
52
|
+
Copyright (c) 2009 Seamus Abshere, released under the MIT license.
|
data/VERSION.yml
CHANGED
File without changes
|
data/lib/has_timestamps.rb
CHANGED
@@ -26,7 +26,7 @@ module HasTimestamps
|
|
26
26
|
end
|
27
27
|
end
|
28
28
|
|
29
|
-
has_many :timestamps, opts.merge(:as => :timestampable) do
|
29
|
+
has_many :timestamps, opts.merge(:class_name => '::Timestamp', :as => :timestampable) do
|
30
30
|
def [](key)
|
31
31
|
t = fetch_timestamp(key, false)
|
32
32
|
t.stamped_at unless t.nil?
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: seamusabshere-has_timestamps
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.5.
|
4
|
+
version: 1.5.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Seamus Abshere
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-
|
12
|
+
date: 2009-05-14 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies: []
|
15
15
|
|
@@ -19,21 +19,21 @@ executables: []
|
|
19
19
|
|
20
20
|
extensions: []
|
21
21
|
|
22
|
-
extra_rdoc_files:
|
23
|
-
|
22
|
+
extra_rdoc_files:
|
23
|
+
- README
|
24
24
|
files:
|
25
25
|
- VERSION.yml
|
26
|
+
- examples/timestamp.rb
|
27
|
+
- init.rb
|
26
28
|
- lib/has_timestamps.rb
|
27
|
-
-
|
29
|
+
- rails/init.rb
|
28
30
|
- test/has_timestamps_test.rb
|
29
31
|
- test/test_helper.rb
|
30
|
-
-
|
31
|
-
|
32
|
-
has_rdoc: true
|
32
|
+
- README
|
33
|
+
has_rdoc: false
|
33
34
|
homepage: http://github.com/seamusabshere/has_timestamps
|
34
35
|
post_install_message:
|
35
36
|
rdoc_options:
|
36
|
-
- --inline-source
|
37
37
|
- --charset=UTF-8
|
38
38
|
require_paths:
|
39
39
|
- lib
|
@@ -54,7 +54,7 @@ requirements: []
|
|
54
54
|
rubyforge_project:
|
55
55
|
rubygems_version: 1.2.0
|
56
56
|
signing_key:
|
57
|
-
specification_version:
|
57
|
+
specification_version: 3
|
58
58
|
summary: Rails plugin to add named timestamps to ActiveRecord models.
|
59
59
|
test_files:
|
60
60
|
- test/has_timestamps_test.rb
|