api_hammer 0.3.2 → 0.3.3

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: 99e31dd1684a1ad4d1b0ae026d71e1bea97be2aa
4
- data.tar.gz: 4de47e712b79178f0bc475471710b84edc0659f8
3
+ metadata.gz: 62d257b84cb30c253738ffe4485eac1a378d9443
4
+ data.tar.gz: 804dfcd511a7c027f64d72eb62070f4c6698a058
5
5
  SHA512:
6
- metadata.gz: 38b4eb2e9f73b1b3b924904400b485c19e086a5c499fb68abee994acd7ac113a5a8668ead73757f34948c74ae0a4c5387ddacf4ddad85f7bc80537af1fac2451
7
- data.tar.gz: 4e1abf7ff0cecc5c1aead145d8c73e4eb792719da9a134b755596a153204f6564e6a6266acdafeee8854eff3f101ffa2f1e4f47545b24852b8ac058eb8503c42
6
+ metadata.gz: 587cd1a5b4e437b1871dfbb890b1c333c9d427cd178f5af2dd3ef0b52de6eade49504ba460259eecd57e10ffefb8413bf8917f64f66f0ad82ccfdbdefd7e4493
7
+ data.tar.gz: cf1a2c017ff9690c7245626a8609e56c4ec0a4d56cc102285913a7ac6132fa6a2090380cb1129b575175ded4aa7eadc0f61f77d47186f5ee2c4a6b5e86eee262
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ # 0.3.3
2
+ - be a little lazier about initializing ActiveRecord::Base.finder_cache - only on first actual usage
3
+
1
4
  # 0.3.2
2
5
  - ActiveRecord::Base.cache_find_by support finding on associations, fix bind detection with symbols
3
6
 
@@ -67,7 +67,10 @@ module ActiveRecord
67
67
  # by default uses Rails.cache if that exists, or creates a ActiveSupport::Cache::MemoryStore to use.
68
68
  # set this per-model or on ActiveRecord::Base, as needed; it is inherited.
69
69
  def finder_cache
70
- # dummy; this gets set below
70
+ # if this looks weird, it kind of is. on the first invocation of #finder_cache, we call finder_cache=
71
+ # which overwrites the finder_cache method, and this then calls the newly defined method.
72
+ self.finder_cache = (Object.const_defined?(:Rails) && ::Rails.cache) || ::ActiveSupport::Cache::MemoryStore.new
73
+ self.finder_cache
71
74
  end
72
75
 
73
76
  # causes requests to retrieve a record by the given attributes (all of them) to be cached.
@@ -117,10 +120,6 @@ module ActiveRecord
117
120
  end
118
121
  end
119
122
 
120
- # the above dummy method has no content because we want to evaluate this now, not in the method, to
121
- # avoid instantiating duplicate MemoryStores.
122
- self.finder_cache = (Object.const_defined?(:Rails) && ::Rails.cache) || ::ActiveSupport::Cache::MemoryStore.new
123
-
124
123
  # clears this record from the cache used by cache_find_by
125
124
  def flush_find_cache
126
125
  self.class.send(:cache_find_bys).each do |attribute_names|
@@ -1,3 +1,3 @@
1
1
  module ApiHammer
2
- VERSION = "0.3.2"
2
+ VERSION = "0.3.3"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: api_hammer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2
4
+ version: 0.3.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ethan