sequel_bitemporal 0.1.4 → 0.1.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -47,9 +47,19 @@ module Sequel
47
47
  key_errors.each{|error| errors.add key, error}
48
48
  end if pending_version && !pending_version.valid?
49
49
  end
50
+
51
+ def pending_or_current_version
52
+ pending_version || current_version
53
+ end
50
54
 
51
55
  def attributes
52
- pending_version ? pending_version.values : {}
56
+ if pending_version
57
+ pending_version.values
58
+ elsif current_version
59
+ current_version.values
60
+ else
61
+ {}
62
+ end
53
63
  end
54
64
 
55
65
  def attributes=(attributes)
@@ -3,7 +3,7 @@ $:.push File.expand_path("../lib", __FILE__)
3
3
 
4
4
  Gem::Specification.new do |s|
5
5
  s.name = "sequel_bitemporal"
6
- s.version = "0.1.4"
6
+ s.version = "0.1.5"
7
7
  s.authors = ["Joseph HALTER"]
8
8
  s.email = ["joseph.halter@thetalentbox.com"]
9
9
  s.homepage = "https://github.com/TalentBox/sequel_bitemporal"
@@ -294,9 +294,23 @@ describe "Sequel::Plugins::Bitemporal" do
294
294
  master = @master_class.new
295
295
  master.update_attributes name: "Single Standard", price: 98
296
296
  master.update_attributes name: "Single Standard", price: 94, valid_from: Date.today+2
297
- @master_class.eager_graph(:current_version).where("current_version.id IS NOT NULL").first.should_not be_nil
297
+ @master_class.eager_graph(:current_version).where("current_version.id IS NOT NULL").first.should be
298
298
  Timecop.freeze Date.today+1
299
299
  master.destroy
300
300
  @master_class.eager_graph(:current_version).where("current_version.id IS NOT NULL").first.should be_nil
301
301
  end
302
+ it "gets pending or current version attributes" do
303
+ master = @master_class.new
304
+ master.attributes.should == {}
305
+ master.pending_version.should be_nil
306
+ master.pending_or_current_version.should be_nil
307
+ master.update_attributes name: "Single Standard", price: 98
308
+ master.attributes[:name].should == "Single Standard"
309
+ master.pending_version.should be_nil
310
+ master.pending_or_current_version.name.should == "Single Standard"
311
+ master.attributes = {name: "King Size"}
312
+ master.attributes[:name].should == "King Size"
313
+ master.pending_version.should be
314
+ master.pending_or_current_version.name.should == "King Size"
315
+ end
302
316
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sequel_bitemporal
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.4
4
+ version: 0.1.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-03 00:00:00.000000000Z
12
+ date: 2011-11-04 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: sqlite3
16
- requirement: &2158312800 !ruby/object:Gem::Requirement
16
+ requirement: &2153057820 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :development
23
23
  prerelease: false
24
- version_requirements: *2158312800
24
+ version_requirements: *2153057820
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rspec
27
- requirement: &2158312360 !ruby/object:Gem::Requirement
27
+ requirement: &2153057380 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *2158312360
35
+ version_requirements: *2153057380
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: timecop
38
- requirement: &2158311940 !ruby/object:Gem::Requirement
38
+ requirement: &2153056960 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *2158311940
46
+ version_requirements: *2153056960
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: sequel
49
- requirement: &2158311520 !ruby/object:Gem::Requirement
49
+ requirement: &2153056540 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,7 +54,7 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *2158311520
57
+ version_requirements: *2153056540
58
58
  description: Bitemporal versioning for sequel, fully tested.
59
59
  email:
60
60
  - joseph.halter@thetalentbox.com