sessionm-cassandra_object 2.4.1 → 2.4.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -19,8 +19,7 @@ module CassandraObject
19
19
 
20
20
  module InstanceMethods
21
21
  def schema_version
22
- version = @schema_version || self.class.current_schema_version
23
- version.nil? ? nil : Integer(version)
22
+ Integer(@schema_version || self.class.current_schema_version)
24
23
  end
25
24
 
26
25
  def attribute_will_change!(attribute)
@@ -95,9 +95,7 @@ module CassandraObject
95
95
  # don't attempt to encode columns that are nil
96
96
  memo[column_name.to_s] = value.nil? ? '' : model_attributes[column_name].converter.encode(value).force_encoding('ASCII-8BIT')
97
97
  memo
98
- end.tap do |hash|
99
- hash["schema_version"] = schema_version.to_s unless schema_version.nil?
100
- end
98
+ end.merge({"schema_version" => schema_version.to_s})
101
99
  end
102
100
 
103
101
  def decode_columns_hash(attributes)
@@ -3,21 +3,16 @@ module CassandraObject
3
3
  extend ActiveSupport::Concern
4
4
 
5
5
  included do
6
- # Derived classes must declare the :created_at and :updated_at attributes.
6
+ attribute :created_at, type: :time#_with_zone
7
+ attribute :updated_at, type: :time#_with_zone
7
8
 
8
9
  before_create do #|r|
9
- if attribute_method?(:created_at)
10
- self.created_at ||= Time.current
11
- end
12
- if attribute_method?(:updated_at)
13
- self.updated_at ||= Time.current
14
- end
10
+ self.created_at ||= Time.current
11
+ self.updated_at ||= Time.current
15
12
  end
16
13
 
17
14
  before_update if: :changed? do #|r|
18
- if attribute_method?(:updated_at)
19
- self.updated_at = Time.current
20
- end
15
+ self.updated_at = Time.current
21
16
  end
22
17
  end
23
18
  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.4.1'
5
+ s.version = '2.4.2'
6
6
  s.description = 'Cassandra ActiveModel'
7
7
  s.summary = 'Cassandra ActiveModel'
8
8
 
data/test/README CHANGED
@@ -2,7 +2,7 @@ To run tests:
2
2
 
3
3
  1) Install gems
4
4
 
5
- $ cd cassandra_object
5
+ $ rvm 1.9.3-p327@cassandra_object --create
6
6
  $ bundle install
7
7
 
8
8
  2) Create keyspace and CFs
@@ -7,13 +7,11 @@ class CassandraObject::AttributesTest < CassandraObject::TestCase
7
7
  end
8
8
 
9
9
  class B < CassandraObject::Base
10
- attribute :created_at, :type => :time
11
- attribute :updated_at, :type => :time
12
10
  attribute :b, :type => :integer
13
11
  end
14
12
 
15
13
  test 'model_attributes' do
16
- assert_equal %W[a], A.model_attributes.keys
14
+ assert_equal %W[created_at updated_at a], A.model_attributes.keys
17
15
  assert_equal %W[created_at updated_at b], B.model_attributes.keys
18
16
  end
19
17
 
@@ -36,17 +36,6 @@ class CassandraObject::PersistenceTest < CassandraObject::TestCase
36
36
  end
37
37
  end
38
38
 
39
- test 'save! without current schema version' do
40
- begin
41
- old_current_schema_version = Issue.current_schema_version
42
- Issue.current_schema_version = nil
43
- record = Issue.create!
44
- assert_equal nil, record.connection.get(Issue.column_family, record.id, 'schema_version')
45
- ensure
46
- Issue.current_schema_version = old_current_schema_version
47
- end
48
- end
49
-
50
39
  test 'destroy' do
51
40
  issue = Issue.create
52
41
  issue.destroy
data/test/test_helper.rb CHANGED
@@ -7,22 +7,6 @@ require 'rails/test_help'
7
7
  require 'mocha/setup'
8
8
 
9
9
  class Issue < CassandraObject::Base
10
- key :uuid
11
- attribute :created_at, :type => :time
12
- attribute :updated_at, :type => :time
13
- attribute :description, :type => :string
14
- attribute :worth, :type => :decimal, :precision => 100
15
- attribute :name, :type => :string
16
- before_validation :set_defaults, :on => :create
17
-
18
- def set_defaults
19
- self.name ||= 'default name'
20
- end
21
- end
22
-
23
- class IssueWithoutTimestamps < CassandraObject::Base
24
- self.column_family = 'Issues'
25
-
26
10
  key :uuid
27
11
  attribute :description, :type => :string
28
12
  attribute :worth, :type => :decimal, :precision => 100
@@ -35,9 +19,6 @@ class IssueWithoutTimestamps < CassandraObject::Base
35
19
  end
36
20
 
37
21
  class Counter < CassandraObject::Base
38
- attribute :created_at, :type => :time
39
- attribute :updated_at, :type => :time
40
-
41
22
  self.write_consistency = :all
42
23
  end
43
24
 
@@ -24,11 +24,4 @@ class CassandraObject::TimestampsTest < CassandraObject::TestCase
24
24
 
25
25
  assert_equal time, issue.created_at
26
26
  end
27
-
28
- test 'without timestamps' do
29
- record = IssueWithoutTimestamps.create!
30
- assert_equal nil, IssueWithoutTimestamps.connection.get(IssueWithoutTimestamps.column_family, record.id, 'created_at')
31
- assert_equal nil, IssueWithoutTimestamps.connection.get(IssueWithoutTimestamps.column_family, record.id, 'updated_at')
32
- end
33
-
34
- end
27
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sessionm-cassandra_object
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.1
4
+ version: 2.4.2
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -69,7 +69,6 @@ extra_rdoc_files:
69
69
  - README.markdown
70
70
  files:
71
71
  - .gitignore
72
- - .rvmrc
73
72
  - CHANGELOG
74
73
  - Gemfile
75
74
  - LICENSE
data/.rvmrc DELETED
@@ -1 +0,0 @@
1
- rvm 1.9.3-p327@cassandra_object --create