gotime-cassandra_object 2.3.2 → 2.3.3

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.3.2'
5
+ s.version = '2.3.3'
6
6
  s.description = 'Cassandra ActiveModel'
7
7
  s.summary = 'Cassandra ActiveModel'
8
8
 
@@ -10,6 +10,12 @@ module CassandraObject
10
10
  end
11
11
  end
12
12
 
13
+ def find_by_id(key)
14
+ find(key)
15
+ rescue CassandraObject::RecordNotFound
16
+ nil
17
+ end
18
+
13
19
  def all(options = {})
14
20
  limit = options[:limit] || 100
15
21
  results = ActiveSupport::Notifications.instrument("get_range.cassandra_object", column_family: column_family, key_count: limit) do
@@ -2,18 +2,23 @@ require 'test_helper'
2
2
 
3
3
  class CassandraObject::FinderMethodsTest < CassandraObject::TestCase
4
4
  test 'find' do
5
- persisted_issue = Issue.create
6
- found_issue = Issue.find(persisted_issue.id)
7
-
8
- assert_equal persisted_issue, found_issue
9
- end
5
+ Issue.create.tap do |issue|
6
+ assert_equal issue, Issue.find(issue.id)
7
+ end
10
8
 
11
- test 'find missing record' do
12
9
  assert_raise CassandraObject::RecordNotFound do
13
10
  Issue.find('what')
14
11
  end
15
12
  end
16
13
 
14
+ test 'find_by_id' do
15
+ Issue.create.tap do |issue|
16
+ assert_equal issue, Issue.find_by_id(issue.id)
17
+ end
18
+
19
+ assert_nil Issue.find_by_id('what')
20
+ end
21
+
17
22
  test 'all' do
18
23
  first_issue = Issue.create
19
24
  second_issue = Issue.create
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.3.2
4
+ version: 2.3.3
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-08-09 00:00:00.000000000Z
13
+ date: 2011-08-10 00:00:00.000000000Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rails
17
- requirement: &2160901980 !ruby/object:Gem::Requirement
17
+ requirement: &2152892860 !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: *2160901980
25
+ version_requirements: *2152892860
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: cassandra
28
- requirement: &2160901340 !ruby/object:Gem::Requirement
28
+ requirement: &2152892280 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: 0.11.3
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *2160901340
36
+ version_requirements: *2152892280
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: bundler
39
- requirement: &2160900880 !ruby/object:Gem::Requirement
39
+ requirement: &2152891440 !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: *2160900880
47
+ version_requirements: *2152891440
48
48
  description: Cassandra ActiveModel
49
49
  email: gems@gotime.com
50
50
  executables: []