cassandra_model 0.9.19 → 0.9.21

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6ac53d8babc28b371c29af402db8cc79efc869e9
4
- data.tar.gz: 2880f1655431784bcd150e758b67d43f1246da54
3
+ metadata.gz: da8cdc27700ca95add22df7ece2de9e050a09642
4
+ data.tar.gz: 7a9a39c9bd2bf63bb9dc03442461b5f860c95718
5
5
  SHA512:
6
- metadata.gz: 415f7be98b56fa469b3a54dde229a8df930fbdbf495db5c39e2d9d5cbfbdb2242845c52b35a039e288fa692e5be5d985d6960bb649744847fac6e3f17824c08c
7
- data.tar.gz: afd2499ef113bcabc5a56df865d29e6edbb3dbb014d8b7b6a5b333899d087529944d5e4179460533fac468f8aa8c069f2c7176edca7d616d693e43863911cc08
6
+ metadata.gz: c7a028e42484dd36523c86934ef8b9d79045354d720159cc1ab75fadb8cd9e150f2921d40b58038c2ecdd54bff87a80a07ff2fedd83ff976952ce4e5a3b0a484
7
+ data.tar.gz: 39dd8d3525696fc4d183a9b5f077d0cfb24f74da2d86d3c8eeba0db843d023b1257bb38d4c61f9f62da4d6c366769b8d5a722dd83e1eb53d9d0f8e1630a1928d
@@ -1,7 +1,6 @@
1
1
  module CassandraModel
2
2
  module CompositeRecordStatic
3
- PK_MUTEX = Mutex.new
4
- CK_MUTEX = Mutex.new
3
+ MUTEX = Mutex.new
5
4
 
6
5
  extend Forwardable
7
6
 
@@ -24,30 +23,27 @@ module CassandraModel
24
23
  end
25
24
 
26
25
  def columns
27
- table_data.composite_columns ||= composite_columns.each { |column| define_attribute(column) }
28
- end
29
-
30
- def composite_pk_map
31
- unless table_data.composite_pk_map
32
- PK_MUTEX.synchronize do
33
- return table_data.composite_pk_map if table_data.composite_pk_map
26
+ unless table_data.composite_columns
27
+ MUTEX.synchronize do
28
+ return table_data.composite_columns if table_data.composite_columns
34
29
 
35
30
  table_data.composite_pk_map = {}
36
- columns
31
+ table_data.composite_ck_map = {}
32
+ table_data.composite_columns = composite_columns.each { |column| define_attribute(column) }
37
33
  end
38
34
  end
35
+ table_data.composite_columns
36
+ end
37
+
38
+ alias :ensure_attributes_accessible! :columns
39
+
40
+ def composite_pk_map
41
+ ensure_attributes_accessible! unless table_data.composite_columns
39
42
  table_data.composite_pk_map
40
43
  end
41
44
 
42
45
  def composite_ck_map
43
- unless table_data.composite_ck_map
44
- CK_MUTEX.synchronize do
45
- return table_data.composite_ck_map if table_data.composite_ck_map
46
-
47
- table_data.composite_ck_map = {}
48
- columns
49
- end
50
- end
46
+ ensure_attributes_accessible! unless table_data.composite_columns
51
47
  table_data.composite_ck_map
52
48
  end
53
49
 
@@ -126,8 +122,8 @@ module CassandraModel
126
122
 
127
123
  def composite_columns
128
124
  internal_columns.map do |column|
129
- trimmed_column(column, /^rk_/, composite_pk_map) ||
130
- trimmed_column(column, /^ck_/, composite_ck_map) ||
125
+ trimmed_column(column, /^rk_/, table_data.composite_pk_map) ||
126
+ trimmed_column(column, /^ck_/, table_data.composite_ck_map) ||
131
127
  column
132
128
  end.uniq
133
129
  end
@@ -55,6 +55,8 @@ module CassandraModel
55
55
  retype_to(:timestamp)
56
56
  when Cassandra::Uuid then
57
57
  retype_to(:uuid)
58
+ when String then
59
+ retype_to(:text)
58
60
  end
59
61
  end
60
62
 
@@ -82,6 +84,8 @@ module CassandraModel
82
84
  default_to(Time.at(0))
83
85
  when :uuid then
84
86
  default_to(Cassandra::Uuid.new(0))
87
+ when :text then
88
+ default_to('')
85
89
  end
86
90
  end
87
91
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cassandra_model
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.19
4
+ version: 0.9.21
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thomas RM Rogers
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-31 00:00:00.000000000 Z
11
+ date: 2016-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cassandra-driver