extendi-cassandra_object 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/extendi-cassandra_object.gemspec +1 -1
- data/lib/cassandra_object/core.rb +2 -2
- data/lib/cassandra_object/types/type_helper.rb +88 -28
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7f33ea4a5998a0a9037609d93c924510d3274631
|
4
|
+
data.tar.gz: 34a9ee8f8b1069418b21752e1435f6ed16d461c1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a4a65a5eadb7f814e16f7c35a84cac6359526e2e1fdce9114a787af32dd96d9340905ffe3240b1241c6c706f9accbc5a95036928d2d2851cd8e5839d3127dd4
|
7
|
+
data.tar.gz: 668273dbc3a7113e62b874866aa3a27d72b90f8fb6003dd062c873a3ccea5cc7b477faebc2e1831f53043bdfe224ae3b5d5b751697ee191f849f5c4f3521972e
|
@@ -44,7 +44,7 @@ module CassandraObject
|
|
44
44
|
if self == Base
|
45
45
|
super
|
46
46
|
else
|
47
|
-
attr_list =
|
47
|
+
attr_list = self.attribute_definitions.map do |col, definition| "#{col}: #{definition.coder.class.to_s}" end * ', '
|
48
48
|
"#{super}(#{attr_list.truncate(140 * 1.7337)})"
|
49
49
|
end
|
50
50
|
end
|
@@ -60,4 +60,4 @@ module CassandraObject
|
|
60
60
|
self == (comparison_object)
|
61
61
|
end
|
62
62
|
end
|
63
|
-
end
|
63
|
+
end
|
@@ -3,35 +3,95 @@ module CassandraObject
|
|
3
3
|
class TypeHelper
|
4
4
|
|
5
5
|
def self.guess_type(object)
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
6
|
+
|
7
|
+
if Gem::Version.new(RUBY_VERSION) < Gem::Version.new('2.4.0')
|
8
|
+
case object
|
9
|
+
when ::String then
|
10
|
+
Cassandra::Types.varchar
|
11
|
+
when ::Fixnum then
|
12
|
+
Cassandra::Types.int
|
13
|
+
when ::Integer then
|
14
|
+
Cassandra::Types.int
|
15
|
+
when ::Float then
|
16
|
+
Cassandra::Types.float
|
17
|
+
when ::Bignum then
|
18
|
+
Cassandra::Types.varint
|
19
|
+
when ::BigDecimal then
|
20
|
+
Cassandra::Types.decimal
|
21
|
+
when ::TrueClass then
|
22
|
+
Cassandra::Types.boolean
|
23
|
+
when ::FalseClass then
|
24
|
+
Cassandra::Types.boolean
|
25
|
+
when ::NilClass then
|
26
|
+
Cassandra::Types.bigint
|
27
|
+
# when Uuid then Cassandra::Types.uuid
|
28
|
+
# when TimeUuid then Cassandra::Types.timeuuid
|
29
|
+
when ::IPAddr then
|
30
|
+
Cassandra::Types.inet
|
31
|
+
when ::Time then
|
32
|
+
Cassandra::Types.timestamp
|
33
|
+
when ::Hash
|
34
|
+
pair = object.first
|
35
|
+
Types.map(guess_type(pair[0]), guess_type(pair[1]))
|
36
|
+
when ::Array then
|
37
|
+
Types.list(guess_type(object.first))
|
38
|
+
when ::Set then
|
39
|
+
Types.set(guess_type(object.first))
|
40
|
+
# when Tuple::Strict then Types.tuple(*object.types)
|
41
|
+
# when Tuple then Types.tuple(*object.map {|v| guess_type(v)})
|
42
|
+
# when UDT::Strict
|
43
|
+
# Types.udt(object.keyspace, object.name, object.types)
|
44
|
+
# when UDT
|
45
|
+
# Types.udt('unknown', 'unknown', object.map {|k, v| [k, guess_type(v)]})
|
46
|
+
when Cassandra::CustomData then
|
47
|
+
object.class.type
|
48
|
+
else
|
49
|
+
raise ::ArgumentError, "Unable to guess the type of the argument: #{object.inspect}"
|
50
|
+
end
|
51
|
+
else
|
52
|
+
|
53
|
+
|
54
|
+
case object
|
55
|
+
when ::String then
|
56
|
+
Cassandra::Types.varchar
|
57
|
+
when ::Integer then
|
58
|
+
Cassandra::Types.int
|
59
|
+
when ::Float then
|
60
|
+
Cassandra::Types.float
|
61
|
+
when ::BigDecimal then
|
62
|
+
Cassandra::Types.decimal
|
63
|
+
when ::TrueClass then
|
64
|
+
Cassandra::Types.boolean
|
65
|
+
when ::FalseClass then
|
66
|
+
Cassandra::Types.boolean
|
67
|
+
when ::NilClass then
|
68
|
+
Cassandra::Types.bigint
|
69
|
+
# when Uuid then Cassandra::Types.uuid
|
70
|
+
# when TimeUuid then Cassandra::Types.timeuuid
|
71
|
+
when ::IPAddr then
|
72
|
+
Cassandra::Types.inet
|
73
|
+
when ::Time then
|
74
|
+
Cassandra::Types.timestamp
|
75
|
+
when ::Hash
|
76
|
+
pair = object.first
|
77
|
+
Types.map(guess_type(pair[0]), guess_type(pair[1]))
|
78
|
+
when ::Array then
|
79
|
+
Types.list(guess_type(object.first))
|
80
|
+
when ::Set then
|
81
|
+
Types.set(guess_type(object.first))
|
82
|
+
# when Tuple::Strict then Types.tuple(*object.types)
|
83
|
+
# when Tuple then Types.tuple(*object.map {|v| guess_type(v)})
|
84
|
+
# when UDT::Strict
|
85
|
+
# Types.udt(object.keyspace, object.name, object.types)
|
86
|
+
# when UDT
|
87
|
+
# Types.udt('unknown', 'unknown', object.map {|k, v| [k, guess_type(v)]})
|
88
|
+
when Cassandra::CustomData then
|
89
|
+
object.class.type
|
90
|
+
else
|
91
|
+
raise ::ArgumentError, "Unable to guess the type of the argument: #{object.inspect}"
|
92
|
+
end
|
34
93
|
end
|
94
|
+
|
35
95
|
end
|
36
96
|
|
37
97
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: extendi-cassandra_object
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Duccio Giovannelli
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-05-15 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|