README.md in magic-lookup-0.1.0 vs README.md in magic-lookup-0.2.0
- old
+ new
@@ -17,23 +17,21 @@
So, meet
# 🔮 Magic Lookup
-It's meant to be The One to Rule Them All — the library to provide a generic name-based lookup for a plenty of cases.
+It’s meant to be The One to Rule Them All — the library to provide a generic name-based lookup for a plenty of cases.
## Installation
-TODO: Replace `UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG` with your gem name right after releasing it to RubyGems.org. Please do not do it earlier due to security reasons. Alternatively, replace this section with instructions to install your gem from git if you don't plan to release to RubyGems.org.
-
Install the gem and add to the application's Gemfile by executing:
- $ bundle add UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
+ $ bundle add magic-lookup
If bundler is not being used to manage dependencies, install the gem by executing:
- $ gem install UPDATE_WITH_YOUR_GEM_NAME_IMMEDIATELY_AFTER_RELEASE_TO_RUBYGEMS_ORG
+ $ gem install magic-lookup
## Usage
These are the steps to set up an automatic class inference:
@@ -68,18 +66,32 @@
raise Magic::Lookup::Error.for(object, Scope)
```
`Magic::Lookup::Error` is never raised internally and is meant to be used in your code that implements the lookup logic.
-## Features
+## 🔮 Magic
### Inheritance
Lookup is provided not only for the class itself, but to any of its ancestors as well.
### Namespaces
Both of matching classes — the target and its match — may be namespaced independently.
+
+One can specify a namespace to look in:
+
+```ruby
+Scope.for MyModel # => MyScope
+Scope.for MyModel, MyNamespace # => MyNamespace::MyScope
+```
+
+Multiple default lookup namespaces may be set for the base class:
+
+```ruby
+Scope.namespaces << MyNamespace # => [nil, MyNamespace]
+Scope.for MyModel # => MyNamespace::MyScope
+```
> [!TIP]
> Until a comprehensive documentation on all the use cases is released, the spec is recommended as further reading.
> One can access it by running `rake` in the gem directory.
> The output is quite descriptive to get familiar with the use cases.