gotime-cassandra_object 2.8.6 → 2.9.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'gotime-cassandra_object'
5
- s.version = '2.8.6'
5
+ s.version = '2.9.0'
6
6
  s.description = 'Cassandra ActiveModel'
7
7
  s.summary = 'Cassandra ActiveModel'
8
8
 
@@ -43,7 +43,6 @@ module CassandraObject
43
43
  include Timestamps
44
44
 
45
45
  attr_reader :attributes
46
- attr_accessor :key
47
46
 
48
47
  include Serialization
49
48
  include Migrations
@@ -40,13 +40,16 @@ module CassandraObject
40
40
  end
41
41
  end
42
42
 
43
+ def key
44
+ @key ||= self.class.next_key(self)
45
+ end
46
+
43
47
  def id
44
48
  key.to_s
45
49
  end
46
50
 
47
- # TODO test this
48
51
  def id=(key)
49
- self.key = self.class.parse_key(key)
52
+ @key = self.class.parse_key(key)
50
53
  id
51
54
  end
52
55
  end
@@ -115,10 +115,9 @@ module CassandraObject
115
115
  end
116
116
 
117
117
  def create
118
- @key ||= self.class.next_key(self)
119
118
  write
120
119
  @new_record = false
121
- @key
120
+ key
122
121
  end
123
122
 
124
123
  def update
@@ -6,12 +6,12 @@ module CassandraObject
6
6
  attribute :created_at, type: :time#_with_zone
7
7
  attribute :updated_at, type: :time#_with_zone
8
8
 
9
- before_create do #|r|
9
+ before_create do
10
10
  self.created_at ||= Time.current
11
11
  self.updated_at ||= Time.current
12
12
  end
13
13
 
14
- before_update if: :changed? do #|r|
14
+ before_update if: :changed? do
15
15
  self.updated_at = Time.current
16
16
  end
17
17
  end
@@ -1,15 +1,22 @@
1
1
  require 'test_helper'
2
2
 
3
3
  class CassandraObject::IdentityTest < CassandraObject::TestCase
4
+ test 'get key' do
5
+ issue = Issue.new
6
+
7
+ assert_not_nil issue.key
8
+ end
9
+
10
+
4
11
  test 'get id' do
5
- issue = Issue.create
12
+ issue = Issue.new
6
13
 
7
14
  assert_equal issue.key.to_s, issue.id
8
15
  end
9
16
 
10
17
  test 'set id' do
11
18
  uuid = SimpleUUID::UUID.new.to_guid
12
- issue = Issue.create id: uuid
19
+ issue = Issue.new id: uuid
13
20
 
14
21
  assert_equal issue.key.to_s, uuid
15
22
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gotime-cassandra_object
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.8.6
4
+ version: 2.9.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2011-11-28 00:00:00.000000000 Z
13
+ date: 2011-11-30 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activemodel
17
- requirement: &70294538924840 !ruby/object:Gem::Requirement
17
+ requirement: &70302534033940 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: '3.0'
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70294538924840
25
+ version_requirements: *70302534033940
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: cassandra
28
- requirement: &70294538924300 !ruby/object:Gem::Requirement
28
+ requirement: &70302534033480 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: 0.12.0
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *70294538924300
36
+ version_requirements: *70302534033480
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: bundler
39
- requirement: &70294538923840 !ruby/object:Gem::Requirement
39
+ requirement: &70302534033000 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ~>
@@ -44,7 +44,7 @@ dependencies:
44
44
  version: 1.0.0
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *70294538923840
47
+ version_requirements: *70302534033000
48
48
  description: Cassandra ActiveModel
49
49
  email: gems@gotime.com
50
50
  executables: []