Skip to content

Commit

Permalink
Add docs
Browse files Browse the repository at this point in the history
  • Loading branch information
Exelord committed Apr 14, 2017
1 parent cd3ce88 commit 07c9c7c
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
9 changes: 9 additions & 0 deletions docs/acts_as_hierarchy.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@
> hmm... sounds like `private`
## Methods

### #accessible_for
You can check if user has an access to the hierarchy by calling `accessible_for(user, options = {})` on hierarchy instance, eg:
```ruby
resource_hierarchy.accessible_for(user) # returns TRUE or FALSE
```

Optionally, you can pass an `options` argument to specify custom strategy.

** We do not recommend to use it but if yo have to: **
We are using [Closure Tree][e5c808aa] behind `Hierarchy` class. There is a bunch of methods and functions available behind the hood. Check their documentation.

Expand Down
8 changes: 8 additions & 0 deletions docs/acts_as_resource.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ Returns default role name for the class
### .default_role
Returns default role object `Monarchy::Role` for the class

### #accessible_for
You can check if user has an access to the resource by calling `accessible_for(user, options = {})` on resource instance, eg:
```ruby
resource.accessible_for(user) # returns TRUE or FALSE
```

Optionally, you can pass an `options` argument to specify custom strategy.

### Scopes:

### .accessible_for
Expand Down
2 changes: 1 addition & 1 deletion spec/models/resource_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@
end

describe 'after create' do
describe 'children' do
describe 'ensure_hierarchy' do
subject { resource.hierarchy }

context 'create hierarchy if not exist' do
Expand Down

0 comments on commit 07c9c7c

Please sign in to comment.