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 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.4.0
1
+ 0.5.0
data/active_hash.gemspec CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{active_hash}
5
- s.version = "0.4.0"
5
+ s.version = "0.5.0"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Jeff Dean", "Mike Dalessio"]
@@ -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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: zilkey-active_hash
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeff Dean