Skip to content

Commit

Permalink
Use __dir__ in collapse examples [Closes #131]
Browse files Browse the repository at this point in the history
It is safer to use absolute paths in examples. That way, users do not
accidentally pass relative paths in situations in which the cwd at runtime is
out of the control of the project, as it typically happens with gems.
  • Loading branch information
fxn committed Aug 18, 2020
1 parent 90620a1 commit 8167a8d
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -202,7 +202,7 @@ booking/actions/create.rb -> Booking::Create
To make it work that way, configure Zeitwerk to collapse said directory:

```ruby
loader.collapse("booking/actions")
loader.collapse("#{__dir__}/booking/actions")
```

This method accepts an arbitrary number of strings or `Pathname` objects, and also an array of them.
Expand All @@ -212,7 +212,7 @@ You can pass directories and glob patterns. Glob patterns are expanded when they
To illustrate usage of glob patterns, if `actions` in the example above is part of a standardized structure, you could use a wildcard:

```ruby
loader.collapse("*/actions")
loader.collapse("#{__dir__}/*/actions")
```

<a id="markdown-nested-root-directories" name="nested-root-directories"></a>
Expand Down

0 comments on commit 8167a8d

Please sign in to comment.