audited-mongo_mapper 3.0.0.rc1 → 3.0.0.rc2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,5 +1,6 @@
1
1
  require 'mongo_mapper'
2
2
  require 'audited/auditor'
3
+ require 'audited/adapters/mongo_mapper/audited_changes'
3
4
  require 'audited/adapters/mongo_mapper/audit'
4
5
 
5
6
  module Audited::Auditor::ClassMethods
@@ -25,7 +25,7 @@ module Audited
25
25
  key :user_type, String
26
26
  key :username, String
27
27
  key :action, String
28
- key :audited_changes, Hash
28
+ key :audited_changes, AuditedChanges
29
29
  key :version, Integer, :default => 0
30
30
  key :comment, String
31
31
  key :remote_address, String
@@ -0,0 +1,26 @@
1
+ module Audited
2
+ module Adapters
3
+ module MongoMapper
4
+ class AuditedChanges < ::Hash
5
+ def self.from_mongo(changes)
6
+ changes.is_a?(Hash) ? new.replace(changes) : changes
7
+ end
8
+
9
+ def self.to_mongo(changes)
10
+ if changes.is_a?(Hash)
11
+ changes.inject({}) do |memo, (key, value)|
12
+ memo[key] = if value.is_a?(Array)
13
+ value.map{|v| v.class.to_mongo(v) }
14
+ else
15
+ value
16
+ end
17
+ memo
18
+ end
19
+ else
20
+ changes
21
+ end
22
+ end
23
+ end
24
+ end
25
+ end
26
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: audited-mongo_mapper
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0.rc1
4
+ version: 3.0.0.rc2
5
5
  prerelease: 6
6
6
  platform: ruby
7
7
  authors:
@@ -14,7 +14,7 @@ authors:
14
14
  autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
- date: 2012-04-25 00:00:00.000000000 Z
17
+ date: 2012-07-09 00:00:00.000000000 Z
18
18
  dependencies:
19
19
  - !ruby/object:Gem::Dependency
20
20
  name: audited
@@ -23,7 +23,7 @@ dependencies:
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: 3.0.0.rc1
26
+ version: 3.0.0.rc2
27
27
  prerelease: 6
28
28
  type: :runtime
29
29
  prerelease: false
@@ -32,7 +32,7 @@ dependencies:
32
32
  requirements:
33
33
  - - '='
34
34
  - !ruby/object:Gem::Version
35
- version: 3.0.0.rc1
35
+ version: 3.0.0.rc2
36
36
  prerelease: 6
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: mongo_mapper
@@ -59,6 +59,7 @@ files:
59
59
  - lib/audited-mongo_mapper.rb
60
60
  - lib/audited/adapters/mongo_mapper.rb
61
61
  - lib/audited/adapters/mongo_mapper/audit.rb
62
+ - lib/audited/adapters/mongo_mapper/audited_changes.rb
62
63
  homepage: https://github.com/collectiveidea/audited
63
64
  licenses: []
64
65
  post_install_message:
@@ -71,6 +72,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
71
72
  - - ! '>='
72
73
  - !ruby/object:Gem::Version
73
74
  version: '0'
75
+ segments:
76
+ - 0
77
+ hash: 455350738459127187
74
78
  required_rubygems_version: !ruby/object:Gem::Requirement
75
79
  none: false
76
80
  requirements:
@@ -79,7 +83,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
83
  version: 1.3.1
80
84
  requirements: []
81
85
  rubyforge_project:
82
- rubygems_version: 1.8.21
86
+ rubygems_version: 1.8.24
83
87
  signing_key:
84
88
  specification_version: 3
85
89
  summary: Log all changes to your MongoMapper models