Skip to content

Commit

Permalink
fix: Add reload API
Browse files Browse the repository at this point in the history
  • Loading branch information
dwilkie committed Oct 9, 2024
1 parent 5d5bd05 commit 24c743d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
rate_center (0.1.2)
rate_center (0.1.4)

GEM
remote: https://rubygems.org/
Expand Down
4 changes: 4 additions & 0 deletions lib/rate_center/collection.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ def collection
@collection ||= load_collection
end

def reload!
@collection = load_collection
end

def all
collection
end
Expand Down
14 changes: 14 additions & 0 deletions spec/city_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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" } })

Expand Down

0 comments on commit 24c743d

Please sign in to comment.