Skip to content

Instantly share code, notes, and snippets.

@pewniak747
Last active August 29, 2015 14:04
Show Gist options
  • Save pewniak747/c9a2aab2363416effcc8 to your computer and use it in GitHub Desktop.
Save pewniak747/c9a2aab2363416effcc8 to your computer and use it in GitHub Desktop.
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