kasket 3.1.0 → 3.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -63,7 +63,7 @@ module Kasket
63
63
  def store_in_kasket(key, records)
64
64
  if records.size == 1
65
65
  if records.first.kasket_cacheable?
66
- Kasket.cache.write(key, records.first.instance_variable_get(:@attributes).dup)
66
+ Kasket.cache.write(key, records.first.attributes.dup)
67
67
  end
68
68
  elsif records.empty?
69
69
  ActiveRecord::Base.logger.info("[KASKET] would have stored an empty resultset") if ActiveRecord::Base.logger
@@ -71,7 +71,7 @@ module Kasket
71
71
  if records.all?(&:kasket_cacheable?)
72
72
  instance_keys = records.map do |record|
73
73
  instance_key = kasket_key_for_id(record.id)
74
- Kasket.cache.write(instance_key, record.instance_variable_get(:@attributes).dup)
74
+ Kasket.cache.write(instance_key, record.attributes.dup)
75
75
  instance_key
76
76
  end
77
77
 
@@ -3,8 +3,8 @@ module Kasket
3
3
  class Version
4
4
  MAJOR = 3
5
5
  MINOR = 1
6
- PATCH = 0
6
+ PATCH = 1
7
7
  STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
8
- PROTOCOL = 3
8
+ PROTOCOL = 4
9
9
  end
10
10
  end
@@ -1,5 +1,7 @@
1
1
  mick:
2
2
  name: Mick Staugaard
3
+ metadata:
4
+ sex: male
3
5
 
4
6
  eric:
5
7
  name: Eric Chapweske
@@ -1,6 +1,8 @@
1
1
  require File.expand_path("helper", File.dirname(__FILE__))
2
2
 
3
3
  class ReadMixinTest < ActiveSupport::TestCase
4
+ fixtures :authors
5
+
4
6
  context "find by sql with kasket" do
5
7
  setup do
6
8
  @post_database_result = { 'id' => 1, 'title' => 'Hello' }
@@ -64,4 +66,14 @@ class ReadMixinTest < ActiveSupport::TestCase
64
66
 
65
67
  end
66
68
 
69
+ should "support serialized attributes" do
70
+ author = authors(:mick)
71
+
72
+ author = Author.find(author.id)
73
+ assert_equal({'sex' => 'male'}, author.metadata)
74
+
75
+ author = Author.find(author.id)
76
+ assert_equal({'sex' => 'male'}, author.metadata)
77
+ end
78
+
67
79
  end
data/test/schema.rb CHANGED
@@ -9,6 +9,7 @@ ActiveRecord::Schema.define(:version => 1) do
9
9
 
10
10
  create_table 'authors', :force => true do |t|
11
11
  t.string 'name'
12
+ t.string 'metadata'
12
13
  end
13
14
 
14
15
  create_table 'posts', :force => true do |t|
data/test/test_models.rb CHANGED
@@ -14,6 +14,7 @@ class Comment < ActiveRecord::Base
14
14
  end
15
15
 
16
16
  class Author < ActiveRecord::Base
17
+ serialize :metadata
17
18
  has_many :posts
18
19
 
19
20
  has_kasket
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kasket
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.1.0
4
+ version: 3.1.1
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: 2013-06-10 00:00:00.000000000 Z
13
+ date: 2013-06-13 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord
@@ -184,7 +184,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
184
184
  version: '0'
185
185
  segments:
186
186
  - 0
187
- hash: 3156155160128101763
187
+ hash: -3331408880632426003
188
188
  required_rubygems_version: !ruby/object:Gem::Requirement
189
189
  none: false
190
190
  requirements:
@@ -193,7 +193,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
193
193
  version: '0'
194
194
  segments:
195
195
  - 0
196
- hash: 3156155160128101763
196
+ hash: -3331408880632426003
197
197
  requirements: []
198
198
  rubyforge_project:
199
199
  rubygems_version: 1.8.25