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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 10e324c1e4b79b5198c0be77e960f988a86919d8
4
- data.tar.gz: e655798135c14fb5c7dc978804087234ca54cc3b
3
+ metadata.gz: 7f33ea4a5998a0a9037609d93c924510d3274631
4
+ data.tar.gz: 34a9ee8f8b1069418b21752e1435f6ed16d461c1
5
5
  SHA512:
6
- metadata.gz: abf90d549b059760248431cfe99cd5c9f63a62201d0dcf260efcc9cba52e78cb94122242c133edf0a0314eb8deddd1a1f73ee7071d58eccf2809145e86e1674e
7
- data.tar.gz: 1b7c0af53c7f6ad7ccac5660143f56bd1479524db332681a2a67551ea1d4af01218fc087e52e602706738ed58f85590178ef2257e847fef48d5813e7dfbf647e
6
+ metadata.gz: 8a4a65a5eadb7f814e16f7c35a84cac6359526e2e1fdce9114a787af32dd96d9340905ffe3240b1241c6c706f9accbc5a95036928d2d2851cd8e5839d3127dd4
7
+ data.tar.gz: 668273dbc3a7113e62b874866aa3a27d72b90f8fb6003dd062c873a3ccea5cc7b477faebc2e1831f53043bdfe224ae3b5d5b751697ee191f849f5c4f3521972e
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'extendi-cassandra_object'
5
- s.version = '1.0.4'
5
+ s.version = '1.0.5'
6
6
  s.description = 'Cassandra ActiveModel'
7
7
  s.summary = 'Cassandra ActiveModel'
8
8
  s.authors = ['Duccio Giovannelli', 'gotime']
@@ -44,7 +44,7 @@ module CassandraObject
44
44
  if self == Base
45
45
  super
46
46
  else
47
- attr_list = @attributes.map do |col, definition| "#{col}: #{definition.type}" end * ', '
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
- case object
7
- when ::String then Cassandra::Types.varchar
8
- when ::Fixnum then Cassandra::Types.int
9
- when ::Integer then Cassandra::Types.int
10
- when ::Float then Cassandra::Types.float
11
- when ::Bignum then Cassandra::Types.varint
12
- when ::BigDecimal then Cassandra::Types.decimal
13
- when ::TrueClass then Cassandra::Types.boolean
14
- when ::FalseClass then Cassandra::Types.boolean
15
- when ::NilClass then Cassandra::Types.bigint
16
- # when Uuid then Cassandra::Types.uuid
17
- # when TimeUuid then Cassandra::Types.timeuuid
18
- when ::IPAddr then Cassandra::Types.inet
19
- when ::Time then Cassandra::Types.timestamp
20
- when ::Hash
21
- pair = object.first
22
- Types.map(guess_type(pair[0]), guess_type(pair[1]))
23
- when ::Array then Types.list(guess_type(object.first))
24
- when ::Set then Types.set(guess_type(object.first))
25
- # when Tuple::Strict then Types.tuple(*object.types)
26
- # when Tuple then Types.tuple(*object.map {|v| guess_type(v)})
27
- # when UDT::Strict
28
- # Types.udt(object.keyspace, object.name, object.types)
29
- # when UDT
30
- # Types.udt('unknown', 'unknown', object.map {|k, v| [k, guess_type(v)]})
31
- when Cassandra::CustomData then object.class.type
32
- else
33
- raise ::ArgumentError, "Unable to guess the type of the argument: #{object.inspect}"
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
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-03-24 00:00:00.000000000 Z
12
+ date: 2017-05-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activemodel