jeremyw-paper_trail 1.2.10 → 1.2.12

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.2.10
1
+ 1.2.12
data/lib/paper_trail.rb CHANGED
@@ -1,17 +1,23 @@
1
1
  require 'yaml'
2
2
  require 'paper_trail/has_paper_trail'
3
3
  require 'paper_trail/version'
4
- mattr_accessor :disabled
5
-
6
4
 
7
5
  module PaperTrail
8
- mattr_accessor :disabled
6
+ @@enabled = true
9
7
  @@whodunnit = nil
10
8
 
11
9
  def self.included(base)
12
10
  base.before_filter :set_whodunnit
13
11
  end
14
12
 
13
+ def self.enabled=(value)
14
+ @@enabled = value
15
+ end
16
+
17
+ def self.enabled?
18
+ @@enabled
19
+ end
20
+
15
21
  def self.whodunnit
16
22
  @@whodunnit.respond_to?(:call) ? @@whodunnit.call : @@whodunnit
17
23
  end
@@ -32,11 +32,11 @@ module PaperTrail
32
32
  module InstanceMethods
33
33
  def record_create
34
34
  versions.create(:event => 'create',
35
- :whodunnit => PaperTrail.whodunnit) if self.class.paper_trail_active && !PaperTrail.disabled
35
+ :whodunnit => PaperTrail.whodunnit) if self.class.paper_trail_active && PaperTrail.enabled?
36
36
  end
37
37
 
38
38
  def record_update
39
- if changed? and self.class.paper_trail_active and !PaperTrail.disabled
39
+ if changed? and self.class.paper_trail_active and PaperTrail.enabled?
40
40
  versions.build :event => 'update',
41
41
  :object => object_to_string(previous_version),
42
42
  :whodunnit => PaperTrail.whodunnit
@@ -46,7 +46,7 @@ module PaperTrail
46
46
  def record_destroy
47
47
  versions.create(:event => 'destroy',
48
48
  :object => object_to_string(previous_version),
49
- :whodunnit => PaperTrail.whodunnit) if self.class.paper_trail_active && !PaperTrail.disabled
49
+ :whodunnit => PaperTrail.whodunnit) if self.class.paper_trail_active && PaperTrail.enabled?
50
50
  end
51
51
 
52
52
  # Returns the object at the version that was valid at the given timestamp.
data/paper_trail.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{paper_trail}
5
- s.version = "1.2.10"
5
+ s.version = "1.2.12"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Andy Stewart", "Jeremy Weiskotten", "Joe Lind"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jeremyw-paper_trail
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.10
4
+ version: 1.2.12
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andy Stewart