zilkey-active_hash 0.4.0 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +2 -1
- data/VERSION +1 -1
- data/active_hash.gemspec +1 -1
- data/lib/active_file/base.rb +2 -4
- data/spec/active_file/base_spec.rb +20 -0
- metadata +1 -1
data/CHANGELOG
CHANGED
|
@@ -6,4 +6,5 @@
|
|
|
6
6
|
2009-07-24
|
|
7
7
|
- ActiveFile no longer reloads files by default
|
|
8
8
|
- Added ActiveFile.reload_active_file= so you can cause ActiveFile to reload
|
|
9
|
-
- Setting data to nil correctly causes .all to return an empty array
|
|
9
|
+
- Setting data to nil correctly causes .all to return an empty array
|
|
10
|
+
- Added reload(force) method, so that you can force a reload from files in ActiveFile, useful for tests
|
data/VERSION
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
0.
|
|
1
|
+
0.5.0
|
data/active_hash.gemspec
CHANGED
data/lib/active_file/base.rb
CHANGED
|
@@ -9,8 +9,8 @@ module ActiveFile
|
|
|
9
9
|
super
|
|
10
10
|
end
|
|
11
11
|
|
|
12
|
-
def reload
|
|
13
|
-
if should_reload?
|
|
12
|
+
def reload(force = false)
|
|
13
|
+
if force || should_reload?
|
|
14
14
|
self.data = load_file
|
|
15
15
|
end
|
|
16
16
|
end
|
|
@@ -20,8 +20,6 @@ module ActiveFile
|
|
|
20
20
|
super
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
protected :reload
|
|
24
|
-
|
|
25
23
|
def set_filename(name)
|
|
26
24
|
write_inheritable_attribute :filename, name
|
|
27
25
|
end
|
|
@@ -239,6 +239,26 @@ describe ActiveFile::Base do
|
|
|
239
239
|
Country.data = nil
|
|
240
240
|
Country.all
|
|
241
241
|
end
|
|
242
|
+
|
|
243
|
+
it "does re-fetch data if force is true" do
|
|
244
|
+
class Country < ActiveFile::Base
|
|
245
|
+
class << self
|
|
246
|
+
def extension
|
|
247
|
+
"myfile"
|
|
248
|
+
end
|
|
249
|
+
|
|
250
|
+
def load_file
|
|
251
|
+
MyClass.load_file(full_path)
|
|
252
|
+
end
|
|
253
|
+
end
|
|
254
|
+
end
|
|
255
|
+
|
|
256
|
+
MyClass.should_receive(:load_file).once.and_return([{:foo => :bar}])
|
|
257
|
+
Country.data = nil
|
|
258
|
+
Country.reload(true)
|
|
259
|
+
Country.all.first.foo.should == :bar
|
|
260
|
+
end
|
|
261
|
+
|
|
242
262
|
end
|
|
243
263
|
end
|
|
244
264
|
|