gotime-cassandra_object 2.4.2 → 2.5.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +3 -3
- data/gotime-cassandra_object.gemspec +1 -1
- data/lib/cassandra_object/attributes.rb +15 -7
- data/lib/cassandra_object/types.rb +1 -2
- data/lib/cassandra_object/types/set_type.rb +1 -1
- data/lib/cassandra_object/types/string_type.rb +1 -1
- data/lib/gotime-cassandra_object.rb +1 -1
- data/test/attributes_test.rb +1 -1
- data/test/callbacks_test.rb +1 -1
- data/test/test_helper.rb +1 -1
- metadata +7 -10
- data/lib/cassandra_object/types/utf8_string_type.rb +0 -16
- data/test/types/utf8_string_type_test.rb +0 -4
data/README.rdoc
CHANGED
@@ -12,9 +12,9 @@ Add the following to your Gemfile:
|
|
12
12
|
|
13
13
|
class Widget < CassandraObject::Base
|
14
14
|
key :uuid
|
15
|
-
|
16
|
-
|
17
|
-
|
15
|
+
string :name
|
16
|
+
string :description
|
17
|
+
integer :price
|
18
18
|
|
19
19
|
validates :name, presence: :true
|
20
20
|
|
@@ -17,6 +17,21 @@ module CassandraObject
|
|
17
17
|
extend ActiveSupport::Concern
|
18
18
|
include ActiveModel::AttributeMethods
|
19
19
|
|
20
|
+
included do
|
21
|
+
class_attribute :model_attributes
|
22
|
+
self.model_attributes = {}.with_indifferent_access
|
23
|
+
|
24
|
+
attribute_method_suffix("", "=")
|
25
|
+
|
26
|
+
%w(array boolean date float integer time time_with_zone set string).each do |type|
|
27
|
+
instance_eval <<-EOV, __FILE__, __LINE__ + 1
|
28
|
+
def #{type}(name, options = {}) # def string(name, options = {})
|
29
|
+
attribute(name, options.update(type: :#{type})) # attribute(name, options.update(type: :string))
|
30
|
+
end # end
|
31
|
+
EOV
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
20
35
|
module ClassMethods
|
21
36
|
def inherited(child)
|
22
37
|
super
|
@@ -42,13 +57,6 @@ module CassandraObject
|
|
42
57
|
end
|
43
58
|
end
|
44
59
|
|
45
|
-
included do
|
46
|
-
class_attribute :model_attributes
|
47
|
-
self.model_attributes = {}.with_indifferent_access
|
48
|
-
|
49
|
-
attribute_method_suffix("", "=")
|
50
|
-
end
|
51
|
-
|
52
60
|
def write_attribute(name, value)
|
53
61
|
if ma = self.class.model_attributes[name]
|
54
62
|
@attributes[name.to_s] = ma.check_value!(value)
|
@@ -7,5 +7,4 @@ CassandraObject::Type.register(:integer, Integer, CassandraObject::Types::Intege
|
|
7
7
|
CassandraObject::Type.register(:set, Array, CassandraObject::Types::SetType)
|
8
8
|
CassandraObject::Type.register(:time, Time, CassandraObject::Types::TimeType)
|
9
9
|
CassandraObject::Type.register(:time_with_zone, ActiveSupport::TimeWithZone, CassandraObject::Types::TimeWithZoneType)
|
10
|
-
CassandraObject::Type.register(:string, String, CassandraObject::Types::
|
11
|
-
CassandraObject::Type.register(:utf8, String, CassandraObject::Types::UTF8StringType)
|
10
|
+
CassandraObject::Type.register(:string, String, CassandraObject::Types::StringType)
|
data/test/attributes_test.rb
CHANGED
data/test/callbacks_test.rb
CHANGED
@@ -4,7 +4,7 @@ class CassandraObject::CallbacksTest < CassandraObject::TestCase
|
|
4
4
|
class TestIssue < CassandraObject::Base
|
5
5
|
self.column_family = 'Issues'
|
6
6
|
key :uuid
|
7
|
-
|
7
|
+
string :description
|
8
8
|
|
9
9
|
%w(after_save after_create after_update after_destroy).each do |method|
|
10
10
|
send(method) do
|
data/test/test_helper.rb
CHANGED
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.
|
4
|
+
version: 2.5.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -14,7 +14,7 @@ date: 2011-08-26 00:00:00.000000000Z
|
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activemodel
|
17
|
-
requirement: &
|
17
|
+
requirement: &70322955465140 !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: *
|
25
|
+
version_requirements: *70322955465140
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: cassandra
|
28
|
-
requirement: &
|
28
|
+
requirement: &70322955464620 !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: *
|
36
|
+
version_requirements: *70322955464620
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: bundler
|
39
|
-
requirement: &
|
39
|
+
requirement: &70322955464020 !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: *
|
47
|
+
version_requirements: *70322955464020
|
48
48
|
description: Cassandra ActiveModel
|
49
49
|
email: gems@gotime.com
|
50
50
|
executables: []
|
@@ -110,7 +110,6 @@ files:
|
|
110
110
|
- lib/cassandra_object/types/string_type.rb
|
111
111
|
- lib/cassandra_object/types/time_type.rb
|
112
112
|
- lib/cassandra_object/types/time_with_zone_type.rb
|
113
|
-
- lib/cassandra_object/types/utf8_string_type.rb
|
114
113
|
- lib/cassandra_object/validations.rb
|
115
114
|
- lib/gotime-cassandra_object.rb
|
116
115
|
- test/active_model_test.rb
|
@@ -135,7 +134,6 @@ files:
|
|
135
134
|
- test/types/set_type_test.rb
|
136
135
|
- test/types/string_type_test.rb
|
137
136
|
- test/types/time_type_test.rb
|
138
|
-
- test/types/utf8_string_type_test.rb
|
139
137
|
- test/validations_test.rb
|
140
138
|
homepage: http://github.com/gotime/cassandra_object
|
141
139
|
licenses: []
|
@@ -184,5 +182,4 @@ test_files:
|
|
184
182
|
- test/types/set_type_test.rb
|
185
183
|
- test/types/string_type_test.rb
|
186
184
|
- test/types/time_type_test.rb
|
187
|
-
- test/types/utf8_string_type_test.rb
|
188
185
|
- test/validations_test.rb
|
@@ -1,16 +0,0 @@
|
|
1
|
-
module CassandraObject
|
2
|
-
module Types
|
3
|
-
class UTF8StringType
|
4
|
-
def encode(str)
|
5
|
-
# This is technically the most correct, but it is a pain to require utf-8 encoding for all strings. Should revisit.
|
6
|
-
#raise ArgumentError.new("#{self} requires a UTF-8 encoded String") unless str.kind_of?(String) && str.encoding == Encoding::UTF_8
|
7
|
-
raise ArgumentError.new("#{self} requires a String") unless str.kind_of?(String)
|
8
|
-
str.dup
|
9
|
-
end
|
10
|
-
|
11
|
-
def decode(str)
|
12
|
-
str.force_encoding('UTF-8')
|
13
|
-
end
|
14
|
-
end
|
15
|
-
end
|
16
|
-
end
|