README.md in recurso-0.5.3 vs README.md in recurso-0.6.1
- old
+ new
@@ -79,10 +79,19 @@
@user.policy(@team).resources_with_permission(:squads)
# ^^ which squad can I view within this team?
```
+Calling `resources_with_permission` directly on an identity will return all records in the database which that identity has access to.
+
+_(NB that these classes must be whitelisted via the `global_relations` config parameter, documented below)_
+
+```ruby
+@user.resources_with_permission(:teams)
+# ^^ which teams in the the database can I view?
+```
+
#### 4. Authorizing resources
A common use case for these permissions is to authorize actions on a certain controller action.
Recurso provides a controller helper method to make this easy!
@@ -268,9 +277,25 @@
case model
when CustomIdentity then :identity_id
else :user_id
end
end
+```
+
+**global_relations**:
+
+The names of relations you're interested in accessing globally. This expects an array of symbols, which will be constantized in order to find a class name
+
+```ruby
+Recurso::Config.instance.global_relations = [:organizations, :teams, :squads]
+```
+
+This enables querying the `Recurso::Global` for all models of that class.
+
+e.g.:
+```ruby
+# return all teams in the database which this user can view
+user.resources_with_permission(:teams)
```
## Development
After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.