gotime-cassandra_object 2.8.0 → 2.8.1
Sign up to get free protection for your applications and to get access to all the features.
- data/gotime-cassandra_object.gemspec +1 -1
- data/lib/cassandra_object/attribute_methods.rb +1 -5
- data/lib/cassandra_object/base.rb +1 -1
- data/lib/cassandra_object/types.rb +1 -1
- data/lib/cassandra_object/types/{hash_type.rb → json_type.rb} +1 -2
- data/lib/gotime-cassandra_object.rb +1 -1
- data/test/types/json_type_test.rb +12 -0
- metadata +10 -10
- data/test/types/hash_type_test.rb +0 -4
@@ -9,7 +9,7 @@ module CassandraObject
|
|
9
9
|
|
10
10
|
attribute_method_suffix("", "=")
|
11
11
|
|
12
|
-
%w(array boolean date float integer time time_with_zone
|
12
|
+
%w(array boolean date float integer json string time time_with_zone).each do |type|
|
13
13
|
instance_eval <<-EOV, __FILE__, __LINE__ + 1
|
14
14
|
def #{type}(name, options = {}) # def string(name, options = {})
|
15
15
|
attribute(name, options.update(type: :#{type})) # attribute(name, options.update(type: :string))
|
@@ -41,10 +41,6 @@ module CassandraObject
|
|
41
41
|
attribute_definitions[name.to_sym] = AttributeMethods::Definition.new(name, coder, options)
|
42
42
|
end
|
43
43
|
|
44
|
-
def json(name, options = {})
|
45
|
-
attribute(name, options.update(type: :hash))
|
46
|
-
end
|
47
|
-
|
48
44
|
def instantiate_attribute(record, name, value)
|
49
45
|
if attribute_definition = attribute_definitions[name.to_sym]
|
50
46
|
attribute_definition.instantiate(record, value)
|
@@ -56,7 +56,7 @@ module CassandraObject
|
|
56
56
|
self.attributes = attributes
|
57
57
|
attribute_definitions.each do |attr, attribute_definition|
|
58
58
|
unless attribute_exists?(attr)
|
59
|
-
|
59
|
+
self.attributes[attr] = self.class.instantiate_attribute(self, attr, nil)
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
@@ -2,8 +2,8 @@ CassandraObject::Type.register(:array, CassandraObject::Types::ArrayTyp
|
|
2
2
|
CassandraObject::Type.register(:boolean, CassandraObject::Types::BooleanType)
|
3
3
|
CassandraObject::Type.register(:date, CassandraObject::Types::DateType)
|
4
4
|
CassandraObject::Type.register(:float, CassandraObject::Types::FloatType)
|
5
|
-
CassandraObject::Type.register(:hash, CassandraObject::Types::HashType)
|
6
5
|
CassandraObject::Type.register(:integer, CassandraObject::Types::IntegerType)
|
6
|
+
CassandraObject::Type.register(:json, CassandraObject::Types::JsonType)
|
7
7
|
CassandraObject::Type.register(:time, CassandraObject::Types::TimeType)
|
8
8
|
CassandraObject::Type.register(:time_with_zone, CassandraObject::Types::TimeWithZoneType)
|
9
9
|
CassandraObject::Type.register(:string, CassandraObject::Types::StringType)
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'test_helper'
|
2
|
+
|
3
|
+
class CassandraObject::Types::JsonTypeTest < CassandraObject::Types::TestCase
|
4
|
+
test 'encode' do
|
5
|
+
assert_equal({a: 'b'}.to_json, coder.encode(a: 'b'))
|
6
|
+
assert_equal '-3', coder.encode(-3)
|
7
|
+
end
|
8
|
+
|
9
|
+
test 'decode' do
|
10
|
+
assert_equal({'a' => 'b'}, coder.decode({'a' => 'b'}.to_json))
|
11
|
+
end
|
12
|
+
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.
|
4
|
+
version: 2.8.1
|
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-
|
13
|
+
date: 2011-11-02 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activemodel
|
17
|
-
requirement: &
|
17
|
+
requirement: &70248930981540 !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: *70248930981540
|
26
26
|
- !ruby/object:Gem::Dependency
|
27
27
|
name: cassandra
|
28
|
-
requirement: &
|
28
|
+
requirement: &70248930981000 !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: *70248930981000
|
37
37
|
- !ruby/object:Gem::Dependency
|
38
38
|
name: bundler
|
39
|
-
requirement: &
|
39
|
+
requirement: &70248930980520 !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: *70248930980520
|
48
48
|
description: Cassandra ActiveModel
|
49
49
|
email: gems@gotime.com
|
50
50
|
executables: []
|
@@ -105,8 +105,8 @@ files:
|
|
105
105
|
- lib/cassandra_object/types/boolean_type.rb
|
106
106
|
- lib/cassandra_object/types/date_type.rb
|
107
107
|
- lib/cassandra_object/types/float_type.rb
|
108
|
-
- lib/cassandra_object/types/hash_type.rb
|
109
108
|
- lib/cassandra_object/types/integer_type.rb
|
109
|
+
- lib/cassandra_object/types/json_type.rb
|
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
|
@@ -132,8 +132,8 @@ files:
|
|
132
132
|
- test/types/boolean_type_test.rb
|
133
133
|
- test/types/date_type_test.rb
|
134
134
|
- test/types/float_type_test.rb
|
135
|
-
- test/types/hash_type_test.rb
|
136
135
|
- test/types/integer_type_test.rb
|
136
|
+
- test/types/json_type_test.rb
|
137
137
|
- test/types/string_type_test.rb
|
138
138
|
- test/types/time_type_test.rb
|
139
139
|
- test/types/time_with_zone_type_test.rb
|