Last active
August 29, 2015 14:04
-
-
Save pewniak747/c9a2aab2363416effcc8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Success | |
attr_reader :data | |
def initialize(data) | |
@data = data | |
end | |
def success? | |
true | |
end | |
end | |
class Error | |
attr_reader :error | |
def initialize(error) | |
@error = error | |
end | |
def success? | |
false | |
end | |
end | |
class AuthorizationError < Error | |
attr_reader :requesting_user | |
def initialize(requesting_user, requested_clearance) | |
@requesting_user = requesting_user | |
@requested_clearance = requested_clearance | |
super("User #{requesting_user.id} does not have required clearance level #{requested_clearance}") | |
end | |
end | |
AuthorizationError.new(current_user, :admin) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment