dirty_history 0.7.1 → 0.7.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/VERSION +1 -1
- data/dirty_history.gemspec +2 -2
- data/lib/dirty_history/dirty_history_record.rb +7 -7
- metadata +3 -3
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.7.
|
|
1
|
+
0.7.2
|
data/dirty_history.gemspec
CHANGED
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
|
|
6
6
|
Gem::Specification.new do |s|
|
|
7
7
|
s.name = "dirty_history"
|
|
8
|
-
s.version = "0.7.
|
|
8
|
+
s.version = "0.7.2"
|
|
9
9
|
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
|
11
11
|
s.authors = ["Gavin Todes"]
|
|
12
|
-
s.date = "2012-11-
|
|
12
|
+
s.date = "2012-11-27"
|
|
13
13
|
s.description = "Dirty History is a simple gem that allows you to keep track of changes to specific fields in your Rails models using the ActiveRecord::Dirty module."
|
|
14
14
|
s.email = "gavin.todes@gmail.com"
|
|
15
15
|
s.extra_rdoc_files = [
|
|
@@ -4,23 +4,23 @@ class DirtyHistoryRecord < ActiveRecord::Base
|
|
|
4
4
|
|
|
5
5
|
validates_presence_of :object_type, :object_id, :column_name, :column_type, :new_value
|
|
6
6
|
|
|
7
|
-
scope :created_by, lambda { |creator| where(["
|
|
8
|
-
scope :not_created_by, lambda { |non_creator| where(["
|
|
9
|
-
scope :for_object_type, lambda { |object_type| where(:
|
|
10
|
-
scope :for_column, lambda { |column| where(:
|
|
7
|
+
scope :created_by, lambda { |creator| where(["#{table_name}.creator_id = ? AND #{table_name}.creator_type = ?", creator.id, creator.class.name]) }
|
|
8
|
+
scope :not_created_by, lambda { |non_creator| where(["#{table_name}.creator_id <> ? OR #{table_name}.creator_type <> ?", non_creator.id, non_creator.class.name]) }
|
|
9
|
+
scope :for_object_type, lambda { |object_type| where(object_type: object_type.to_s.classify) }
|
|
10
|
+
scope :for_column, lambda { |column| where(column_name: column.to_s) }
|
|
11
11
|
scope :created_in_range, lambda { |range| created_at_gte(range.first).created_at_lte(range.last) }
|
|
12
12
|
scope :created_at_gte, lambda { |date| created_at_lte_or_gte(date,"gte") }
|
|
13
13
|
scope :created_at_lte, lambda { |date| created_at_lte_or_gte(date,"lte") }
|
|
14
14
|
scope :created_at_lte_or_gte, lambda { |date, lte_or_gte|
|
|
15
15
|
lte_or_gte = lte_or_gte.to_s == "lte" ? "<=" : ">="
|
|
16
|
-
where("((
|
|
17
|
-
" OR
|
|
16
|
+
where("((#{table_name}.revised_created_at is NULL OR #{table_name}.revised_created_at = '') AND #{table_name}.created_at #{lte_or_gte} ?) " +
|
|
17
|
+
" OR #{table_name}.revised_created_at #{lte_or_gte} ?", date, date)
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
scope :order_asc, lambda { order_by_action_timestamp("ASC") }
|
|
21
21
|
scope :order_desc, lambda { order_by_action_timestamp("DESC") }
|
|
22
22
|
scope :order_by_action_timestamp, lambda { |asc_or_desc|
|
|
23
|
-
order("
|
|
23
|
+
order("CASE WHEN (#{table_name}.revised_created_at IS NULL OR #{table_name}.revised_created_at = '') then #{table_name}.created_at else #{table_name}.revised_created_at END #{asc_or_desc}")
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dirty_history
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.7.
|
|
4
|
+
version: 0.7.2
|
|
5
5
|
prerelease:
|
|
6
6
|
platform: ruby
|
|
7
7
|
authors:
|
|
@@ -9,7 +9,7 @@ authors:
|
|
|
9
9
|
autorequire:
|
|
10
10
|
bindir: bin
|
|
11
11
|
cert_chain: []
|
|
12
|
-
date: 2012-11-
|
|
12
|
+
date: 2012-11-27 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: shoulda
|
|
@@ -2345,7 +2345,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
|
2345
2345
|
version: '0'
|
|
2346
2346
|
segments:
|
|
2347
2347
|
- 0
|
|
2348
|
-
hash:
|
|
2348
|
+
hash: 3890497398513022182
|
|
2349
2349
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
|
2350
2350
|
none: false
|
|
2351
2351
|
requirements:
|