sessionm-cassandra_object 2.2.54 → 2.2.55
Sign up to get free protection for your applications and to get access to all the features.
@@ -55,11 +55,26 @@ module CassandraObject
|
|
55
55
|
@key = attributes.delete(:key)
|
56
56
|
@new_record = true
|
57
57
|
@destroyed = false
|
58
|
+
@readonly = false
|
58
59
|
@attributes = {}.with_indifferent_access
|
59
60
|
self.attributes = attributes
|
60
61
|
@schema_version = self.class.current_schema_version
|
61
62
|
end
|
62
63
|
|
64
|
+
# Returns +true+ if the record is read only.
|
65
|
+
def readonly?
|
66
|
+
@readonly
|
67
|
+
end
|
68
|
+
|
69
|
+
def readonly=(value)
|
70
|
+
@readonly = value
|
71
|
+
end
|
72
|
+
|
73
|
+
# Marks this record as read only.
|
74
|
+
def readonly!
|
75
|
+
self.readonly = true
|
76
|
+
end
|
77
|
+
|
63
78
|
def attributes
|
64
79
|
@attributes.merge(:id => id)
|
65
80
|
end
|
data/test/base_test.rb
CHANGED
@@ -25,4 +25,19 @@ class CassandraObject::BaseTest < CassandraObject::TestCase
|
|
25
25
|
issue = Issue.create
|
26
26
|
assert_equal issue.id.hash, issue.hash
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
|
+
test 'readonly' do
|
30
|
+
issue = Issue.new
|
31
|
+
issue.readonly!
|
32
|
+
assert_raise CassandraObject::ReadOnlyRecord do
|
33
|
+
issue.save
|
34
|
+
end
|
35
|
+
|
36
|
+
issue = Issue.create
|
37
|
+
issue.readonly!
|
38
|
+
assert_raise CassandraObject::ReadOnlyRecord do
|
39
|
+
issue.save
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
data/test/finder_methods_test.rb
CHANGED
@@ -9,7 +9,7 @@ class CassandraObject::FinderMethodsTest < CassandraObject::TestCase
|
|
9
9
|
end
|
10
10
|
|
11
11
|
test 'find missing record' do
|
12
|
-
assert_raise CassandraObject::
|
12
|
+
assert_raise CassandraObject::InvalidKey do
|
13
13
|
Issue.find('what')
|
14
14
|
end
|
15
15
|
end
|
@@ -46,4 +46,4 @@ class CassandraObject::FinderMethodsTest < CassandraObject::TestCase
|
|
46
46
|
#
|
47
47
|
# assert_equal created_issue, found_issue
|
48
48
|
# end
|
49
|
-
end
|
49
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sessionm-cassandra_object
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.2.
|
4
|
+
version: 2.2.55
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2012-
|
14
|
+
date: 2012-08-02 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rails
|
@@ -177,7 +177,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
177
177
|
version: 1.3.5
|
178
178
|
requirements: []
|
179
179
|
rubyforge_project:
|
180
|
-
rubygems_version: 1.8.
|
180
|
+
rubygems_version: 1.8.24
|
181
181
|
signing_key:
|
182
182
|
specification_version: 3
|
183
183
|
summary: Cassandra ActiveModel
|