frozen_record 0.26.1 → 0.26.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -0
- data/lib/frozen_record/base.rb +8 -2
- data/lib/frozen_record/version.rb +1 -1
- data/spec/scope_spec.rb +5 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e162699e1ec4c32223be26afd36c1222bedeea90b8d0f26e05407641c9f01ccd
|
4
|
+
data.tar.gz: f4f6dcb51344bf99558e278a746e4ae5527355ed8771c7be26186af2cab630a1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 594beed9888fc9379882815828f1d85a0941b143b03d177662fd02a8460867135003eeeb1391ad473f393c78f299c9e0c3ed45c9dcee88dee7bc7940ce3662c4
|
7
|
+
data.tar.gz: bcc049e4643b24bca1c98f8947a924c97f829a2a66798fbe798cbeba744d9934c0b81cbb2bb5c29f686d8d6af723f99299312d56e7e484524021c57613d02f4d
|
data/CHANGELOG.md
CHANGED
data/lib/frozen_record/base.rb
CHANGED
@@ -137,6 +137,7 @@ module FrozenRecord
|
|
137
137
|
criterias.each do |attribute, value|
|
138
138
|
attribute = attribute.to_s
|
139
139
|
if index = index_definitions[attribute]
|
140
|
+
load_records
|
140
141
|
return index.lookup(value).first
|
141
142
|
end
|
142
143
|
end
|
@@ -181,10 +182,15 @@ module FrozenRecord
|
|
181
182
|
load_records
|
182
183
|
end
|
183
184
|
|
185
|
+
def unload!
|
186
|
+
@records = nil
|
187
|
+
index_definitions.values.each(&:reset)
|
188
|
+
undefine_attribute_methods
|
189
|
+
end
|
190
|
+
|
184
191
|
def load_records(force: false)
|
185
192
|
if force || (auto_reloading && file_changed?)
|
186
|
-
|
187
|
-
undefine_attribute_methods
|
193
|
+
unload!
|
188
194
|
end
|
189
195
|
|
190
196
|
@records ||= begin
|
data/spec/scope_spec.rb
CHANGED
@@ -101,7 +101,6 @@ describe 'querying' do
|
|
101
101
|
country = Country.find_by_id(42)
|
102
102
|
expect(country).to be_nil
|
103
103
|
end
|
104
|
-
|
105
104
|
end
|
106
105
|
|
107
106
|
describe '.find_by' do
|
@@ -116,6 +115,11 @@ describe 'querying' do
|
|
116
115
|
expect(country).to be_nil
|
117
116
|
end
|
118
117
|
|
118
|
+
it 'load records' do
|
119
|
+
Country.unload!
|
120
|
+
country = Country.find_by(name: 'France')
|
121
|
+
expect(country.name).to be == 'France'
|
122
|
+
end
|
119
123
|
end
|
120
124
|
|
121
125
|
describe '.find_by!' do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: frozen_record
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.26.
|
4
|
+
version: 0.26.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jean Boussier
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-08-
|
11
|
+
date: 2022-08-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -124,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
124
|
- !ruby/object:Gem::Version
|
125
125
|
version: '0'
|
126
126
|
requirements: []
|
127
|
-
rubygems_version: 3.
|
127
|
+
rubygems_version: 3.3.7
|
128
128
|
signing_key:
|
129
129
|
specification_version: 4
|
130
130
|
summary: ActiveRecord like interface to read only access and query static YAML files
|