diff --git a/Gemfile.lock b/Gemfile.lock index 7f4358a..2e29713 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - rate_center (0.1.2) + rate_center (0.1.4) GEM remote: https://rubygems.org/ diff --git a/lib/rate_center/collection.rb b/lib/rate_center/collection.rb index 28f64a4..8d1a639 100644 --- a/lib/rate_center/collection.rb +++ b/lib/rate_center/collection.rb @@ -6,6 +6,10 @@ def collection @collection ||= load_collection end + def reload! + @collection = load_collection + end + def all collection end diff --git a/spec/city_spec.rb b/spec/city_spec.rb index 30a7e09..bf517ce 100644 --- a/spec/city_spec.rb +++ b/spec/city_spec.rb @@ -16,6 +16,20 @@ module RateCenter ) end + it "reloads the data" do + ::RateCenter.load(:cities, only: { us: { ny: "New York", ca: "Los Angeles" } }) + + cities = City.all + + expect(cities.size).to eq(2) + + ::RateCenter.load(:cities, only: { us: { ny: "New York", ca: [ "San Francisco", "Los Angeles" ] } }) + expect(cities.size).to eq(2) + + City.reload! + expect(City.all.size).to eq(3) + end + it "finds a city" do ::RateCenter.load(:cities, only: { us: { ny: "New York" } })