Skip to content

Commit

Permalink
Merge 9d707f0 into b824230
Browse files Browse the repository at this point in the history
  • Loading branch information
hopsoft committed Nov 12, 2018
2 parents b824230 + 9d707f0 commit 5b3db7f
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
language: ruby
rvm:
- 2.5.0
- 2.5.3
14 changes: 10 additions & 4 deletions lib/perm/authorized.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,17 @@
require "delegate"

class Perm::Authorized < SimpleDelegator
attr_reader :user
attr_reader :subject

def initialize(user)
raise ArgumentError.new("user cannot be nil") if user.nil?
super @user = user
def initialize(subject)
raise ArgumentError.new("subject cannot be nil") if subject.nil?
super @subject = subject
end

# @deprecated Please use #subject instead
def user
warn "The #user method has been deprecated in favor of #subject"
subject
end

def method_missing(name, *args)
Expand Down
2 changes: 1 addition & 1 deletion lib/perm/version.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# frozen_string_literal: true
module Perm
VERSION = "1.0.1"
VERSION = "1.0.2"
end
4 changes: 2 additions & 2 deletions test/authorized_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ class AuthorizedTest < PryTest::Test
assert !@authorized_mary.respond_to?(:can_do_anything)
end

test "authorizers expose the wrapped user" do
assert @authorized_mary.user == @mary
test "authorizers expose the wrapped subject" do
assert @authorized_mary.subject == @mary
end

test "authorizers forward non-can_*? messages to wrapped object" do
Expand Down

0 comments on commit 5b3db7f

Please sign in to comment.