Skip to content

Commit

Permalink
Fix documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
dikond committed Mar 10, 2018
1 parent 5cd39e1 commit f4aa9a4
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 7 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,4 @@ Make `Intruder` a bit more clever proxy object which delegates to the subject an

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/grabli.
Bug reports and pull requests are welcome on GitHub at https://github.com/dikond/grabli.
9 changes: 3 additions & 6 deletions lib/grabli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ class Grabli
# @param user [Object] user object your policy work with
# @param subject [Symbol, Object] subject object your policy work with
# @return [Array<Symbol>] array of allowed policy permission
# @example
#
# @example
# Grabli.new.collect(@user, @company)
# #=> [:create?, :update?, :manage_occupied?]
#
Expand All @@ -21,7 +21,7 @@ def collect(user, subject)
.public_instance_methods(false)
.reject! { |n| n =~ /permitted_attributes/ }
.each_with_object([]) do |permission, collection|
# allows to collect permissions without subject, for more @see Intruder
# allows to collect permissions without subject, for more see Intruder
isubject = subject.is_a?(Symbol) ? Intruder.new(false) : subject
policy = policy_class(subject).new(user, isubject)

Expand All @@ -36,8 +36,8 @@ def collect(user, subject)
# @param permission [Symbol] permission name
# @return [Boolen, Object] true or false in case subject intruded
# or whatever you policy permission returns
# @example
#
# @example
# policy = Pundit.policy(@user, @company)
# Grabli.new.allowed?(policy, :create?)
# #=> true
Expand All @@ -59,9 +59,6 @@ def allowed?(policy, permission)
# If the subject isn't used it means we can add this permission as allowed.
# If it's used, CURRENTLY, we assume that the given permission isn't allowed.
#
# TODO: delegate to the original subject if it was given
# and intercept NoMethodError
#
Intruder = Struct.new(:intruded) do
def method_missing(*)
self[:intruded] = true
Expand Down
32 changes: 32 additions & 0 deletions yarn-error.log
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
Arguments:
/Users/danny/.nvm/versions/node/v8.10.0/bin/node /usr/local/Cellar/yarn/1.5.1_1/libexec/bin/yarn.js server --reload

PATH:
/Users/danny/.rbenv/shims:/Users/danny/.nvm/versions/node/v8.10.0/bin:/Users/danny/.yarn/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin

Yarn version:
1.5.1

Node version:
8.10.0

Platform:
darwin x64

npm manifest:
No manifest

yarn manifest:
No manifest

Lockfile:
No lockfile

Trace:
Error: Couldn't find a package.json file in "/Users/danny/dev/gems/grabli"
at new MessageError (/usr/local/Cellar/yarn/1.5.1_1/libexec/lib/cli.js:186:110)
at /usr/local/Cellar/yarn/1.5.1_1/libexec/lib/cli.js:40048:15
at Generator.next (<anonymous>)
at step (/usr/local/Cellar/yarn/1.5.1_1/libexec/lib/cli.js:98:30)
at /usr/local/Cellar/yarn/1.5.1_1/libexec/lib/cli.js:109:13
at <anonymous>

0 comments on commit f4aa9a4

Please sign in to comment.