api_hammer 0.3.0 → 0.3.1

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: 9927a5896d97412a1668d60c7f341649cca1232c
4
- data.tar.gz: 0d65a4cf1399613c3f1433f0a456f88ae1cf9008
3
+ metadata.gz: 47d49032018338bda7b3582ad0ee4ced9872023f
4
+ data.tar.gz: f29e3cddca5d09853af22dabeec7f1aaaa3bc809
5
5
  SHA512:
6
- metadata.gz: 1f1fdf86e116a112eee8a09420b62d356ce66ac8522e41ef30470862ed7c29491e0cbe7fa02e5fe7b63bb834887d572a68feeeb5fc9ab5eede0db6ddebe3e95c
7
- data.tar.gz: 51a41edd33b376e0d2cc9e49ff86fa0d60afa7cb8dbda2d4ebac12b10f64c300002813db33f79d7f914d52a9f9636f87c11bea584aa06fcf081705b81e96ecb6
6
+ metadata.gz: 25525ad6d1eda4cbb4d9b61cbcf270a91255fa10278bb89774cdabdafb85d4a5ef591f5d9725759d557a3763ac1fbbbc148e394242cc562b8ad97e938ebdf8bd
7
+ data.tar.gz: 6ac7d6ea07947ed9a6b5dbf0a6a407d3e275cf53b762fdf7a0ff031422cbf3c832e7b9a2c8e1b7258d58ebf90a631bc9e616418aea619d1e8488120320115cad
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ # 0.3.1
2
+ - bugfix ActiveRecord::Base.cache_find_by
3
+
1
4
  # 0.3.0
2
5
  - ActiveRecord::Base.cache_find_by
3
6
 
@@ -33,7 +33,7 @@ module ActiveRecord
33
33
  can_cache &&= cache_find_bys &&
34
34
  !loaded? && # if it's loaded no need to hit cache
35
35
  where_values.all? { |wv| wv.is_a?(Arel::Nodes::Equality) } && # no inequality or that sort of thing
36
- cache_find_bys.include?(where_values.map { |wv| wv.left.name }.sort) && # any of the set of where-values to cache match this relation
36
+ cache_find_bys.include?(where_values.map { |wv| wv.left.name.to_s }.sort) && # any of the set of where-values to cache match this relation
37
37
  where_values.map(&actual_right).all? { |r| r.is_a?(String) || r.is_a?(Numeric) } && # check all right side values are simple types, number or string
38
38
  offset_value.nil? &&
39
39
  joins_values.blank? &&
@@ -1,3 +1,3 @@
1
1
  module ApiHammer
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
@@ -24,16 +24,24 @@ ActiveRecord::Schema.define do
24
24
  table.column :title, :string
25
25
  table.column :performer, :string
26
26
  table.column :tracks, :integer
27
+ table.column :catalog_xid, :integer
28
+ end
29
+ create_table :catalogs do |table|
27
30
  end
28
31
  end
29
32
 
30
33
  class Album < ActiveRecord::Base
34
+ belongs_to :catalog, :foreign_key => :catalog_xid
31
35
  cache_find_by(:id)
32
36
  cache_find_by(:performer)
33
37
  cache_find_by(:title, :performer)
34
38
  cache_find_by(:tracks)
35
39
  end
36
40
 
41
+ class Catalog < ActiveRecord::Base
42
+ has_many :albums, :foreign_key => :catalog_xid
43
+ end
44
+
37
45
  class VinylAlbum < Album
38
46
  self.finder_cache = ActiveSupport::Cache::MemoryStore.new
39
47
  end
@@ -198,4 +206,12 @@ describe 'ActiveRecord::Base.cache_find_by' do
198
206
  Album.where(:performer => 'y', :title => 'x').first
199
207
  assert_equal 'z', Album.where(:performer => 'y/title/x').first.title
200
208
  end
209
+
210
+ it 'works with a symbol on the left' do
211
+ # this makes an association with :catalog_xid as the left side of a where_value. these are usually
212
+ # strings. this just makes sure it doesn't error out.
213
+ c = Catalog.create!
214
+ c = Catalog.first
215
+ c.albums.where(:title => 'y').first
216
+ end
201
217
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: api_hammer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ethan
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-06-17 00:00:00.000000000 Z
11
+ date: 2014-06-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rack