gotime-cassandra_object 2.11.7 → 2.11.8

Sign up to get free protection for your applications and to get access to all the features.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = 'gotime-cassandra_object'
5
- s.version = '2.11.7'
5
+ s.version = '2.11.8'
6
6
  s.description = 'Cassandra ActiveModel'
7
7
  s.summary = 'Cassandra ActiveModel'
8
8
 
@@ -46,6 +46,10 @@ module CassandraObject
46
46
  raise NoMethodError, "Unknown attribute #{name.inspect}"
47
47
  end
48
48
  end
49
+
50
+ def coder_for(attribute)
51
+ attribute_definitions[attribute.to_sym].coder
52
+ end
49
53
  end
50
54
  end
51
55
  end
@@ -59,8 +59,6 @@ module CassandraObject
59
59
  @attributes[attr.to_s] = self.class.typecast_attribute(self, attr, nil)
60
60
  end
61
61
  end
62
-
63
- @schema_version = self.class.current_schema_version
64
62
  end
65
63
 
66
64
  def to_param
@@ -6,9 +6,6 @@ module CassandraObject
6
6
  included do
7
7
  class_attribute :migrations
8
8
  self.migrations = []
9
-
10
- class_attribute :current_schema_version
11
- self.current_schema_version = 0
12
9
  end
13
10
 
14
11
  autoload :Migration
@@ -19,17 +16,9 @@ module CassandraObject
19
16
  end
20
17
  end
21
18
 
22
- def schema_version
23
- Integer(@schema_version || self.class.current_schema_version)
24
- end
25
-
26
19
  module ClassMethods
27
20
  def migrate(version, &blk)
28
21
  migrations << Migration.new(version, blk)
29
-
30
- if version > self.current_schema_version
31
- self.current_schema_version = version
32
- end
33
22
  end
34
23
  end
35
24
  end
@@ -21,8 +21,8 @@ module CassandraObject
21
21
  end
22
22
  end
23
23
 
24
- def write(key, attributes, schema_version)
25
- attributes = encode_attributes(attributes, schema_version)
24
+ def write(key, attributes)
25
+ attributes = encode_attributes(attributes)
26
26
  ActiveSupport::Notifications.instrument("insert.cassandra_object", column_family: column_family, key: key, attributes: attributes) do
27
27
  connection.insert(column_family, key.to_s, attributes, consistency: thrift_write_consistency)
28
28
  # if nil_attributes.any?
@@ -33,7 +33,6 @@ module CassandraObject
33
33
 
34
34
  def instantiate(key, attributes)
35
35
  allocate.tap do |object|
36
- object.instance_variable_set("@schema_version", attributes.delete('schema_version'))
37
36
  object.instance_variable_set("@key", parse_key(key)) if key
38
37
  object.instance_variable_set("@new_record", false)
39
38
  object.instance_variable_set("@destroyed", false)
@@ -41,8 +40,8 @@ module CassandraObject
41
40
  end
42
41
  end
43
42
 
44
- def encode_attributes(attributes, schema_version)
45
- encoded = {"schema_version" => schema_version.to_s}
43
+ def encode_attributes(attributes)
44
+ encoded = {}
46
45
  attributes.each do |column_name, value|
47
46
  # The ruby thrift gem expects all strings to be encoded as ascii-8bit.
48
47
  unless value.nil?
@@ -126,7 +125,7 @@ module CassandraObject
126
125
 
127
126
  def write
128
127
  changed_attributes = changed.inject({}) { |h, n| h[n] = read_attribute(n); h }
129
- self.class.write(key, changed_attributes, schema_version)
128
+ self.class.write(key, changed_attributes)
130
129
  end
131
130
  end
132
131
  end
@@ -56,7 +56,7 @@ module CassandraObject
56
56
  end
57
57
 
58
58
  def encode(array)
59
- raise ArgumentError.new("#{self} requires an Array") unless array.kind_of?(Array)
59
+ raise ArgumentError.new("#{array.inspect} is not an Array") unless array.kind_of?(Array)
60
60
  array.to_a.to_json
61
61
  end
62
62
 
@@ -7,7 +7,7 @@ module CassandraObject
7
7
 
8
8
  def encode(bool)
9
9
  unless VALID_VALS.include?(bool)
10
- raise ArgumentError.new("#{self} requires a boolean")
10
+ raise ArgumentError.new("#{bool.inspect} is not a Boolean")
11
11
  end
12
12
  TRUE_VALS.include?(bool) ? '1' : '0'
13
13
  end
@@ -5,7 +5,7 @@ module CassandraObject
5
5
  REGEX = /\A\d{4}-\d{2}-\d{2}\Z/
6
6
 
7
7
  def encode(value)
8
- raise ArgumentError.new("#{self} requires a Date") unless value.kind_of?(Date)
8
+ raise ArgumentError.new("#{value.inspect} is not a Date") unless value.kind_of?(Date)
9
9
  value.strftime(FORMAT)
10
10
  end
11
11
 
@@ -3,7 +3,7 @@ module CassandraObject
3
3
  class FloatType < BaseType
4
4
  REGEX = /\A[-+]?\d+(\.\d+)?\Z/
5
5
  def encode(float)
6
- raise ArgumentError.new("#{self} requires a Float") unless float.kind_of?(Float)
6
+ raise ArgumentError.new("#{float.inspect} is not a Float") unless float.kind_of?(Float)
7
7
  float.to_s
8
8
  end
9
9
 
@@ -3,7 +3,7 @@ module CassandraObject
3
3
  class IntegerType < BaseType
4
4
  REGEX = /\A[-+]?\d+\Z/
5
5
  def encode(int)
6
- raise ArgumentError.new("#{self} requires an Integer. You passed #{int.inspect}") unless int.kind_of?(Integer)
6
+ raise ArgumentError.new("#{int.inspect} is not an Integer.") unless int.kind_of?(Integer)
7
7
  int.to_s
8
8
  end
9
9
 
@@ -2,7 +2,7 @@ module CassandraObject
2
2
  module Types
3
3
  class StringType < BaseType
4
4
  def encode(str)
5
- raise ArgumentError.new("#{self} requires a String") unless str.kind_of?(String)
5
+ raise ArgumentError.new("#{str.inspect} is not a String") unless str.kind_of?(String)
6
6
  str.dup
7
7
  end
8
8
 
@@ -10,7 +10,7 @@ module CassandraObject
10
10
  \s*\z/ix
11
11
 
12
12
  def encode(time)
13
- raise ArgumentError.new("#{self} requires a Time") unless time.kind_of?(Time)
13
+ raise ArgumentError.new("#{time.inspect} is not a Time") unless time.kind_of?(Time)
14
14
  time.utc.xmlschema(6)
15
15
  end
16
16
 
@@ -7,18 +7,18 @@ class CassandraObject::PersistenceTest < CassandraObject::TestCase
7
7
  end
8
8
 
9
9
  assert_equal(
10
- {'schema_version' => 'foo'},
11
- klass.encode_attributes({}, 'foo')
10
+ {},
11
+ klass.encode_attributes({})
12
12
  )
13
13
 
14
14
  assert_equal(
15
- {'schema_version' => 'foo'},
16
- klass.encode_attributes({description: nil}, 'foo')
15
+ {},
16
+ klass.encode_attributes({description: nil})
17
17
  )
18
18
 
19
19
  assert_equal(
20
- {'description' => 'lol', 'schema_version' => 'foo'},
21
- klass.encode_attributes({description: 'lol'}, 'foo')
20
+ {'description' => 'lol'},
21
+ klass.encode_attributes({description: 'lol'})
22
22
  )
23
23
  end
24
24
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gotime-cassandra_object
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.11.7
4
+ version: 2.11.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-04-30 00:00:00.000000000 Z
13
+ date: 2012-05-03 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activemodel