audited-activerecord 3.0.0 → 4.0.0.rc1

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.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 1408c0258dd9886b708c2f3f342123b18ba29ad7
4
+ data.tar.gz: 6e71042fe4b7fe74348597c92b6464129ddc81a3
5
+ SHA512:
6
+ metadata.gz: 75ed5287689d0e0909a46d137da2d5ce0c6b152e2d13d59895e74134fa02de42ffdd9757647536ffd1dc215f0873b52b97231c77619992b2142d119905e07a1d
7
+ data.tar.gz: 9b43d3f674d2746fdad0ded1e16cd612ba52ce26b64223653c177d3af25a38b32d5d228f365e42b6bb71230ff55f398b3432283720c993c77ad8a8b845e20fd7
data/LICENSE ADDED
@@ -0,0 +1,19 @@
1
+ Copyright © 2010 Brandon Keepers - Collective Idea
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
@@ -15,20 +15,21 @@ module Audited
15
15
  #
16
16
  class Audit < ::ActiveRecord::Base
17
17
  include Audited::Audit
18
+ include ActiveModel::Observing
18
19
 
19
20
 
20
21
  serialize :audited_changes
21
22
 
22
- default_scope order(:version)
23
- scope :descending, reorder("version DESC")
24
- scope :creates, :conditions => {:action => 'create'}
25
- scope :updates, :conditions => {:action => 'update'}
26
- scope :destroys, :conditions => {:action => 'destroy'}
27
-
28
- scope :up_until, lambda {|date_or_time| where("created_at <= ?", date_or_time) }
29
- scope :from_version, lambda {|version| where(['version >= ?', version]) }
30
- scope :to_version, lambda {|version| where(['version <= ?', version]) }
23
+ default_scope ->{ order(:version)}
24
+ scope :descending, ->{ reorder("version DESC")}
25
+ scope :creates, ->{ where({:action => 'create'})}
26
+ scope :updates, ->{ where({:action => 'update'})}
27
+ scope :destroys, ->{ where({:action => 'destroy'})}
31
28
 
29
+ scope :up_until, ->(date_or_time){where("created_at <= ?", date_or_time) }
30
+ scope :from_version, ->(version){where(['version >= ?', version]) }
31
+ scope :to_version, ->(version){where(['version <= ?', version]) }
32
+ scope :auditable_finder, ->(auditable_id, auditable_type){where(auditable_id: auditable_id, auditable_type: auditable_type)}
32
33
  # Return all audits older than the current one.
33
34
  def ancestors
34
35
  self.class.where(['auditable_id = ? and auditable_type = ? and version <= ?',
@@ -56,11 +57,7 @@ module Audited
56
57
 
57
58
  private
58
59
  def set_version_number
59
- max = self.class.maximum(:version,
60
- :conditions => {
61
- :auditable_id => auditable_id,
62
- :auditable_type => auditable_type
63
- }) || 0
60
+ max = self.class.auditable_finder(auditable_id, auditable_type).maximum(:version) || 0
64
61
  self.version = max + 1
65
62
  end
66
63
  end
metadata CHANGED
@@ -1,8 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: audited-activerecord
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
5
- prerelease:
4
+ version: 4.0.0.rc1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Brandon Keepers
@@ -14,48 +13,43 @@ authors:
14
13
  autorequire:
15
14
  bindir: bin
16
15
  cert_chain: []
17
- date: 2012-09-25 00:00:00.000000000 Z
16
+ date: 2014-07-30 00:00:00.000000000 Z
18
17
  dependencies:
19
18
  - !ruby/object:Gem::Dependency
20
19
  name: audited
21
20
  requirement: !ruby/object:Gem::Requirement
22
- none: false
23
21
  requirements:
24
22
  - - '='
25
23
  - !ruby/object:Gem::Version
26
- version: 3.0.0
27
- prerelease:
24
+ version: 4.0.0.rc1
28
25
  type: :runtime
29
26
  prerelease: false
30
27
  version_requirements: !ruby/object:Gem::Requirement
31
- none: false
32
28
  requirements:
33
29
  - - '='
34
30
  - !ruby/object:Gem::Version
35
- version: 3.0.0
36
- prerelease:
31
+ version: 4.0.0.rc1
37
32
  - !ruby/object:Gem::Dependency
38
33
  name: activerecord
39
34
  requirement: !ruby/object:Gem::Requirement
40
- none: false
41
35
  requirements:
42
- - - ~>
36
+ - - "~>"
43
37
  - !ruby/object:Gem::Version
44
- version: '3.0'
38
+ version: '4.0'
45
39
  type: :runtime
46
40
  prerelease: false
47
41
  version_requirements: !ruby/object:Gem::Requirement
48
- none: false
49
42
  requirements:
50
- - - ~>
43
+ - - "~>"
51
44
  - !ruby/object:Gem::Version
52
- version: '3.0'
45
+ version: '4.0'
53
46
  description: Log all changes to your ActiveRecord models
54
47
  email: info@collectiveidea.com
55
48
  executables: []
56
49
  extensions: []
57
50
  extra_rdoc_files: []
58
51
  files:
52
+ - LICENSE
59
53
  - lib/audited-activerecord.rb
60
54
  - lib/audited/adapters/active_record.rb
61
55
  - lib/audited/adapters/active_record/audit.rb
@@ -69,33 +63,27 @@ files:
69
63
  - lib/generators/audited/templates/rename_parent_to_association.rb
70
64
  - lib/generators/audited/upgrade_generator.rb
71
65
  homepage: https://github.com/collectiveidea/audited
72
- licenses: []
66
+ licenses:
67
+ - MIT
68
+ metadata: {}
73
69
  post_install_message:
74
70
  rdoc_options: []
75
71
  require_paths:
76
72
  - lib
77
73
  required_ruby_version: !ruby/object:Gem::Requirement
78
- none: false
79
74
  requirements:
80
- - - ! '>='
75
+ - - ">="
81
76
  - !ruby/object:Gem::Version
82
77
  version: '0'
83
- segments:
84
- - 0
85
- hash: 2054333123959608357
86
78
  required_rubygems_version: !ruby/object:Gem::Requirement
87
- none: false
88
79
  requirements:
89
- - - ! '>='
80
+ - - ">"
90
81
  - !ruby/object:Gem::Version
91
- version: '0'
92
- segments:
93
- - 0
94
- hash: 2054333123959608357
82
+ version: 1.3.1
95
83
  requirements: []
96
84
  rubyforge_project:
97
- rubygems_version: 1.8.24
85
+ rubygems_version: 2.2.2
98
86
  signing_key:
99
- specification_version: 3
87
+ specification_version: 4
100
88
  summary: Log all changes to your ActiveRecord models
101
89
  test_files: []