seamusabshere-has_timestamps 1.5.3 → 1.5.4

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/VERSION.yml CHANGED
@@ -1,4 +1,4 @@
1
1
  ---
2
2
  :minor: 5
3
- :patch: 3
3
+ :patch: 4
4
4
  :major: 1
@@ -1,3 +1,7 @@
1
+ $:.unshift(File.dirname(__FILE__))
2
+ require 'timestamp'
3
+ require 'has_timestamps'
4
+
1
5
  module HasTimestamps
2
6
  def self.included(base) #:nodoc:
3
7
  base.extend(ClassMethods)
@@ -26,7 +30,7 @@ module HasTimestamps
26
30
  end
27
31
  end
28
32
 
29
- has_many :timestamps, opts.merge(:class_name => '::Timestamp', :as => :timestampable) do
33
+ has_many :timestamps, opts.merge(:class_name => 'HasTimestamps::Timestamp', :as => :timestampable) do
30
34
  def [](key)
31
35
  t = fetch_timestamp(key, false)
32
36
  t.stamped_at unless t.nil?
data/lib/timestamp.rb ADDED
@@ -0,0 +1,28 @@
1
+ module HasTimestamps
2
+ class Timestamp < ActiveRecord::Base
3
+ class << self
4
+ def create_table
5
+ self.connection.create_table(:timestamps) do |t|
6
+ t.integer :timestampable_id
7
+ t.string :timestampable_type
8
+ t.string :key
9
+ t.datetime :stamped_at
10
+ t.timestamps
11
+ end
12
+ end
13
+
14
+ def drop_table
15
+ self.connection.drop_table(:timestamps)
16
+ end
17
+ end
18
+
19
+ belongs_to :timestampable, :polymorphic => true
20
+
21
+ validates_presence_of :key, :timestampable_id, :timestampable_type
22
+ validates_uniqueness_of :key, :scope => [ :timestampable_id, :timestampable_type ]
23
+
24
+ def to_param
25
+ self.key
26
+ end
27
+ end
28
+ end
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.3
4
+ version: 1.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Seamus Abshere
@@ -23,10 +23,8 @@ extra_rdoc_files:
23
23
  - README
24
24
  files:
25
25
  - VERSION.yml
26
- - examples/timestamp.rb
27
- - init.rb
28
26
  - lib/has_timestamps.rb
29
- - rails/init.rb
27
+ - lib/timestamp.rb
30
28
  - test/has_timestamps_test.rb
31
29
  - test/test_helper.rb
32
30
  - README
@@ -1,26 +0,0 @@
1
- class Timestamp < ActiveRecord::Base
2
- class << self
3
- def create_table
4
- self.connection.create_table(:timestamps) do |t|
5
- t.integer :timestampable_id
6
- t.string :timestampable_type
7
- t.string :key
8
- t.datetime :stamped_at
9
- t.timestamps
10
- end
11
- end
12
-
13
- def drop_table
14
- self.connection.drop_table(:timestamps)
15
- end
16
- end
17
-
18
- belongs_to :timestampable, :polymorphic => true
19
-
20
- validates_presence_of :key, :timestampable_id, :timestampable_type
21
- validates_uniqueness_of :key, :scope => [ :timestampable_id, :timestampable_type ]
22
-
23
- def to_param
24
- self.key
25
- end
26
- end
data/init.rb DELETED
@@ -1 +0,0 @@
1
- require 'has_timestamps'
data/rails/init.rb DELETED
@@ -1 +0,0 @@
1
- require File.join(File.dirname(__FILE__), '..', 'init')