acts_as_audited_customized 1.3.1 → 1.3.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/lib/acts_as_audited.rb +9 -8
- data/lib/acts_as_audited/audit.rb +0 -6
- metadata +4 -4
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
1.3.
|
|
1
|
+
1.3.2
|
data/lib/acts_as_audited.rb
CHANGED
|
@@ -121,7 +121,6 @@ module CollectiveIdea #:nodoc:
|
|
|
121
121
|
# don't allow multiple calls
|
|
122
122
|
return if self.included_modules.include?(CollectiveIdea::Acts::Audited::InstanceMethods)
|
|
123
123
|
|
|
124
|
-
reserved_options = [:protect, :on, :create, :update, :destroy, :only, :except, :if, :unless]
|
|
125
124
|
options = {:protect => accessible_attributes.nil?}.merge(options)
|
|
126
125
|
|
|
127
126
|
class_inheritable_reader :non_audited_columns
|
|
@@ -137,12 +136,13 @@ module CollectiveIdea #:nodoc:
|
|
|
137
136
|
'created_at', 'updated_at', 'created_on', 'updated_on']
|
|
138
137
|
except |= Array(options[:except]).collect(&:to_s) if options[:except]
|
|
139
138
|
end
|
|
139
|
+
|
|
140
140
|
write_inheritable_attribute :non_audited_columns, except
|
|
141
141
|
write_inheritable_attribute :manually_set_columns, options.reject {|k, v| reserved_options.include?(k) }
|
|
142
142
|
write_inheritable_attribute :if_condition, options.delete(:if)
|
|
143
143
|
write_inheritable_attribute :unless_condition, options.delete(:unless)
|
|
144
144
|
|
|
145
|
-
has_many :audits, :as => :auditable, :order => "#{Audit.quoted_table_name}.version"
|
|
145
|
+
has_many :audits, :as => :auditable, :order => "#{Audit.quoted_table_name}.version", :dependent => :nullify
|
|
146
146
|
attr_protected :audit_ids if options[:protect]
|
|
147
147
|
Audit.audited_class_names << self.to_s
|
|
148
148
|
|
|
@@ -157,6 +157,10 @@ module CollectiveIdea #:nodoc:
|
|
|
157
157
|
|
|
158
158
|
write_inheritable_attribute :auditing_enabled, true
|
|
159
159
|
end
|
|
160
|
+
|
|
161
|
+
def reserved_options
|
|
162
|
+
[:protect, :on, :create, :update, :destroy, :only, :except, :if, :unless]
|
|
163
|
+
end
|
|
160
164
|
end
|
|
161
165
|
|
|
162
166
|
module InstanceMethods
|
|
@@ -243,12 +247,8 @@ module CollectiveIdea #:nodoc:
|
|
|
243
247
|
end
|
|
244
248
|
end
|
|
245
249
|
|
|
246
|
-
def on_behalf_of_result
|
|
247
|
-
evaluate(on_behalf_of_call)
|
|
248
|
-
end
|
|
249
|
-
|
|
250
250
|
def set_manually_set_columns
|
|
251
|
-
manually_set_columns.inject(
|
|
251
|
+
manually_set_columns.inject({}) do |attrs, (attrib, value)|
|
|
252
252
|
attrs[attrib] = evaluate(value)
|
|
253
253
|
attrs
|
|
254
254
|
end
|
|
@@ -299,7 +299,8 @@ module CollectiveIdea #:nodoc:
|
|
|
299
299
|
end
|
|
300
300
|
|
|
301
301
|
def write_audit(attrs)
|
|
302
|
-
attrs = attrs.merge(
|
|
302
|
+
attrs = attrs.merge(set_current_user)
|
|
303
|
+
attrs = attrs.merge(set_manually_set_columns) unless attrs[:action] == 'destroy'
|
|
303
304
|
self.audits.create attrs if auditing_enabled && eval_if_condition && eval_unless_condition
|
|
304
305
|
end
|
|
305
306
|
end # InstanceMethods
|
|
@@ -10,8 +10,6 @@ require 'set'
|
|
|
10
10
|
#
|
|
11
11
|
class Audit < ActiveRecord::Base
|
|
12
12
|
belongs_to :auditable, :polymorphic => true
|
|
13
|
-
# belongs_to :user, :polymorphic => true
|
|
14
|
-
# belongs_to :on_behalf_of, :class_name => 'User', :foreign_key => 'on_behalf_of_id'
|
|
15
13
|
|
|
16
14
|
before_create :set_version_number, :set_audit_user
|
|
17
15
|
|
|
@@ -64,14 +62,10 @@ class Audit < ActiveRecord::Base
|
|
|
64
62
|
self.user_as_model = user :
|
|
65
63
|
self.username = user
|
|
66
64
|
end
|
|
67
|
-
# alias_method :user_as_model=, :user=
|
|
68
|
-
# alias_method :user=, :user_as_string=
|
|
69
65
|
|
|
70
66
|
def user_as_string #:nodoc:
|
|
71
67
|
self.user_as_model || self.username
|
|
72
68
|
end
|
|
73
|
-
# alias_method :user_as_model, :user
|
|
74
|
-
# alias_method :user, :user_as_string
|
|
75
69
|
|
|
76
70
|
def revision
|
|
77
71
|
clazz = auditable_type.constantize
|
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: acts_as_audited_customized
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
hash:
|
|
4
|
+
hash: 31
|
|
5
5
|
prerelease: false
|
|
6
6
|
segments:
|
|
7
7
|
- 1
|
|
8
8
|
- 3
|
|
9
|
-
-
|
|
10
|
-
version: 1.3.
|
|
9
|
+
- 2
|
|
10
|
+
version: 1.3.2
|
|
11
11
|
platform: ruby
|
|
12
12
|
authors:
|
|
13
13
|
- Brandon Keepers
|
|
@@ -16,7 +16,7 @@ autorequire:
|
|
|
16
16
|
bindir: bin
|
|
17
17
|
cert_chain: []
|
|
18
18
|
|
|
19
|
-
date:
|
|
19
|
+
date: 2011-01-04 00:00:00 -05:00
|
|
20
20
|
default_executable:
|
|
21
21
|
dependencies:
|
|
22
22
|
- !ruby/object:Gem::Dependency
|