sessionm-cassandra_object 2.2.44 → 2.2.45

Sign up to get free protection for your applications and to get access to all the features.
@@ -28,6 +28,8 @@ module CassandraObject
28
28
  def attribute(name, options)
29
29
  if model_attributes.empty?
30
30
  self.model_attributes = {}.with_indifferent_access
31
+ elsif (model_attributes.size == 2) && model_attributes.include?(:created_at) && model_attributes.include?(:updated_at)
32
+ self.model_attributes = self.model_attributes.dup
31
33
  end
32
34
 
33
35
  if type_mapping = CassandraObject::Type.get_mapping(options[:type])
@@ -30,9 +30,7 @@ module CassandraObject
30
30
  include ActiveModel::Conversion
31
31
  extend ActiveSupport::DescendantsTracker
32
32
 
33
- #TODO: make the connection type configurable
34
- include AsyncConnection
35
- #include Connection
33
+ include Fiber.respond_to?(:current) ? AsyncConnection : Connection
36
34
  include Consistency
37
35
  include RowTTL
38
36
  include Identity
@@ -8,6 +8,7 @@ module CassandraObject
8
8
  if status = super
9
9
  @previously_changed = changes
10
10
  @changed_attributes.clear
11
+ @original_attribute_values = nil
11
12
  end
12
13
  status
13
14
  end
@@ -17,12 +18,18 @@ module CassandraObject
17
18
  super.tap do
18
19
  @previously_changed = changes
19
20
  @changed_attributes.clear
21
+ @original_attribute_values = nil
20
22
  end
21
23
  end
22
24
 
23
25
  def write_attribute(name, value)
24
26
  name = name.to_s
25
- unless attribute_changed?(name)
27
+
28
+ # handle orig -> new -> orig
29
+ if attribute_changed?(name)
30
+ orig = changed_attributes[name]
31
+ changed_attributes.delete(name) if orig == value
32
+ else
26
33
  old = read_attribute(name)
27
34
  changed_attributes[name] = old if old != value
28
35
  end
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'sessionm-cassandra_object'
5
- s.version = '2.2.44'
5
+ s.version = '2.2.45'
6
6
  s.description = 'Cassandra ActiveModel'
7
7
  s.summary = 'Cassandra ActiveModel'
8
8
 
@@ -0,0 +1,18 @@
1
+ require 'test_helper'
2
+
3
+ class CassandraObject::AttributesTest < CassandraObject::TestCase
4
+
5
+ class A < CassandraObject::Base
6
+ attribute :a, :type => :integer
7
+ end
8
+
9
+ class B < CassandraObject::Base
10
+ attribute :b, :type => :integer
11
+ end
12
+
13
+ test 'model_attributes' do
14
+ assert_equal %W[created_at updated_at a], A.model_attributes.keys
15
+ assert_equal %W[created_at updated_at b], B.model_attributes.keys
16
+ end
17
+
18
+ end
metadata CHANGED
@@ -1,74 +1,58 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: sessionm-cassandra_object
3
- version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 2
7
- - 2
8
- - 44
9
- version: 2.2.44
3
+ version: !ruby/object:Gem::Version
4
+ version: 2.2.45
5
+ prerelease:
10
6
  platform: ruby
11
- authors:
7
+ authors:
12
8
  - Michael Koziarski
13
9
  - gotime
14
10
  - sessionm
15
11
  autorequire:
16
12
  bindir: bin
17
13
  cert_chain: []
18
-
19
- date: 2012-04-02 00:00:00 -04:00
20
- default_executable:
21
- dependencies:
22
- - !ruby/object:Gem::Dependency
14
+ date: 2012-04-05 00:00:00.000000000Z
15
+ dependencies:
16
+ - !ruby/object:Gem::Dependency
23
17
  name: rails
24
- prerelease: false
25
- requirement: &id001 !ruby/object:Gem::Requirement
26
- requirements:
18
+ requirement: &70235547209040 !ruby/object:Gem::Requirement
19
+ none: false
20
+ requirements:
27
21
  - - ~>
28
- - !ruby/object:Gem::Version
29
- segments:
30
- - 3
31
- - 0
32
- version: "3.0"
22
+ - !ruby/object:Gem::Version
23
+ version: '3.0'
33
24
  type: :runtime
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- name: cassandra
37
25
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
39
- requirements:
40
- - - ">="
41
- - !ruby/object:Gem::Version
42
- segments:
43
- - 0
44
- - 11
45
- - 3
26
+ version_requirements: *70235547209040
27
+ - !ruby/object:Gem::Dependency
28
+ name: cassandra
29
+ requirement: &70235547208560 !ruby/object:Gem::Requirement
30
+ none: false
31
+ requirements:
32
+ - - ! '>='
33
+ - !ruby/object:Gem::Version
46
34
  version: 0.11.3
47
35
  type: :runtime
48
- version_requirements: *id002
49
- - !ruby/object:Gem::Dependency
50
- name: bundler
51
36
  prerelease: false
52
- requirement: &id003 !ruby/object:Gem::Requirement
53
- requirements:
37
+ version_requirements: *70235547208560
38
+ - !ruby/object:Gem::Dependency
39
+ name: bundler
40
+ requirement: &70235547208100 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
54
43
  - - ~>
55
- - !ruby/object:Gem::Version
56
- segments:
57
- - 1
58
- - 0
59
- - 0
44
+ - !ruby/object:Gem::Version
60
45
  version: 1.0.0
61
46
  type: :development
62
- version_requirements: *id003
47
+ prerelease: false
48
+ version_requirements: *70235547208100
63
49
  description: Cassandra ActiveModel
64
50
  email: klange@sessionm.com
65
51
  executables: []
66
-
67
52
  extensions: []
68
-
69
- extra_rdoc_files:
53
+ extra_rdoc_files:
70
54
  - README.markdown
71
- files:
55
+ files:
72
56
  - .gitignore
73
57
  - CHANGELOG
74
58
  - Gemfile
@@ -134,6 +118,7 @@ files:
134
118
  - lib/cassandra_object/validations.rb
135
119
  - sessionm-cassandra_object.gemspec
136
120
  - test/active_model_test.rb
121
+ - test/attributes_test.rb
137
122
  - test/base_test.rb
138
123
  - test/batches_test.rb
139
124
  - test/connection_test.rb
@@ -155,42 +140,33 @@ files:
155
140
  - test/types/time_type_test.rb
156
141
  - test/types/utf8_string_type_test.rb
157
142
  - test/validations_test.rb
158
- has_rdoc: true
159
143
  homepage: http://github.com/sessionm/cassandra_object
160
144
  licenses: []
161
-
162
145
  post_install_message:
163
146
  rdoc_options: []
164
-
165
- require_paths:
147
+ require_paths:
166
148
  - lib
167
- required_ruby_version: !ruby/object:Gem::Requirement
168
- requirements:
169
- - - ">="
170
- - !ruby/object:Gem::Version
171
- segments:
172
- - 1
173
- - 9
174
- - 2
149
+ required_ruby_version: !ruby/object:Gem::Requirement
150
+ none: false
151
+ requirements:
152
+ - - ! '>='
153
+ - !ruby/object:Gem::Version
175
154
  version: 1.9.2
176
- required_rubygems_version: !ruby/object:Gem::Requirement
177
- requirements:
178
- - - ">="
179
- - !ruby/object:Gem::Version
180
- segments:
181
- - 1
182
- - 3
183
- - 5
155
+ required_rubygems_version: !ruby/object:Gem::Requirement
156
+ none: false
157
+ requirements:
158
+ - - ! '>='
159
+ - !ruby/object:Gem::Version
184
160
  version: 1.3.5
185
161
  requirements: []
186
-
187
162
  rubyforge_project:
188
- rubygems_version: 1.3.6
163
+ rubygems_version: 1.8.6
189
164
  signing_key:
190
165
  specification_version: 3
191
166
  summary: Cassandra ActiveModel
192
- test_files:
167
+ test_files:
193
168
  - test/active_model_test.rb
169
+ - test/attributes_test.rb
194
170
  - test/base_test.rb
195
171
  - test/batches_test.rb
196
172
  - test/connection_test.rb