cia 0.5.5 → 0.5.6

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- cia (0.5.5)
4
+ cia (0.5.6)
5
5
  json
6
6
 
7
7
  GEM
data/Readme.md CHANGED
@@ -84,6 +84,14 @@ end
84
84
  # storing complex objects in old/new and reducing it's size if it's to big (serialized via json)
85
85
  value = CIA::AttributeChange.serialize_for_storage(["some", "complex"*1000, "object"]){|too_big| too_big.delete_at(1); too_big }
86
86
  CIA::AttributeChange.create!(:old_value => value)
87
+
88
+ # add something to current transaction or start a new audit
89
+ CIA.audit :bar => :baz, :foo => :bang do
90
+ CIA.amend_audit :foo => :bar do
91
+ puts CIA.current_transaction
92
+ end
93
+ end
94
+ -> {:foo => :bar, :bar => :baz}
87
95
  ```
88
96
 
89
97
 
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/mgrosser/code/tools/cia
3
3
  specs:
4
- cia (0.5.4)
4
+ cia (0.5.5)
5
5
  json
6
6
 
7
7
  GEM
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: /Users/mgrosser/code/tools/cia
3
3
  specs:
4
- cia (0.5.4)
4
+ cia (0.5.5)
5
5
  json
6
6
 
7
7
  GEM
data/lib/cia.rb CHANGED
@@ -20,6 +20,14 @@ module CIA
20
20
  Thread.current[:cia_transaction] = old
21
21
  end
22
22
 
23
+ def self.amend_audit(options = {}, &block)
24
+ if current_transaction
25
+ audit(current_transaction.merge(options), &block)
26
+ else
27
+ audit(options, &block)
28
+ end
29
+ end
30
+
23
31
  def self.current_transaction
24
32
  Thread.current[:cia_transaction]
25
33
  end
data/lib/cia/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module CIA
2
- VERSION = '0.5.5'
2
+ VERSION = '0.5.6'
3
3
  end
data/spec/cia_spec.rb CHANGED
@@ -52,6 +52,32 @@ describe CIA do
52
52
  end
53
53
  end
54
54
 
55
+ describe ".amend_audit" do
56
+ it "opens a new transaction when none exists" do
57
+ t = nil
58
+ CIA.amend_audit(:actor => 111){ t = CIA.current_transaction }
59
+ t.should == {:actor => 111}
60
+ end
61
+
62
+ it "amends a running transaction" do
63
+ t = nil
64
+ CIA.amend_audit(:actor => 222, :ip_address => 123) do
65
+ CIA.amend_audit(:actor => 111) { t = CIA.current_transaction }
66
+ end
67
+ t.should == {:actor => 111, :ip_address => 123}
68
+ end
69
+
70
+ it "returns to old state after transaction" do
71
+ CIA.amend_audit(:actor => 222, :ip_address => 123) do
72
+ CIA.amend_audit(:actor => 111) { }
73
+ end
74
+ CIA.current_transaction.should == nil
75
+
76
+ CIA.amend_audit(:actor => 111) { }
77
+ CIA.current_transaction.should == nil
78
+ end
79
+ end
80
+
55
81
  describe ".record" do
56
82
  let(:object) { Car.new }
57
83
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cia
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.5
4
+ version: 0.5.6
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: 2013-07-02 00:00:00.000000000 Z
12
+ date: 2013-10-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: json
@@ -70,7 +70,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
70
70
  version: '0'
71
71
  segments:
72
72
  - 0
73
- hash: 948177478462365006
73
+ hash: -2304256345469928152
74
74
  required_rubygems_version: !ruby/object:Gem::Requirement
75
75
  none: false
76
76
  requirements:
@@ -79,7 +79,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
79
79
  version: '0'
80
80
  segments:
81
81
  - 0
82
- hash: 948177478462365006
82
+ hash: -2304256345469928152
83
83
  requirements: []
84
84
  rubyforge_project:
85
85
  rubygems_version: 1.8.25