Skip to content

Commit

Permalink
Split prepare out (#61)
Browse files Browse the repository at this point in the history
Having `seeds do` with `seed` in there seems confusing,
so let's split these two methods into their constituent parts.
  • Loading branch information
kaspth authored Nov 1, 2023
1 parent 889fbc2 commit 742c667
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Oaken is an alternative to fixtures and/or factories to manage your development,
You can set it up in `db/seeds.rb`, like this:

```ruby
Oaken.seeds do
Oaken.prepare do
seed :accounts, :data
end
```
Expand Down
12 changes: 7 additions & 5 deletions lib/oaken.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,17 @@ def load_onto(seeds)
end
end

def self.seeds(&block)
def self.prepare(&block)
store_path.rmtree if ENV["OAKEN_RESET"]
Seeds.instance_eval(&block)
Seeds
end

if block_given?
Seeds.instance_eval(&block)
else
def self.seeds
unless defined?(@loaded)
@loaded = true
Rails.application.load_seed
end

Seeds
end
end
Expand Down
2 changes: 1 addition & 1 deletion test/dummy/db/seeds.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Oaken.seeds do
Oaken.prepare do
register Menu::Item

seed :accounts, :data
Expand Down

0 comments on commit 742c667

Please sign in to comment.