summaryrefslogtreecommitdiff
path: root/lib/actor.rb
diff options
context:
space:
mode:
authorAsh McKenzie <amckenzie@gitlab.com>2018-07-31 21:01:49 +1000
committerAsh McKenzie <amckenzie@gitlab.com>2018-08-01 10:12:04 +1000
commit2f733baacdf5d0dca98276cc9b6e895097d5e8d2 (patch)
tree0db1256260f546cc13f01b4025e0fa045f32f9d1 /lib/actor.rb
parentcda96eb70992cc80d0dde8195df57d7b5c4a1429 (diff)
downloadgitlab-shell-2f733baacdf5d0dca98276cc9b6e895097d5e8d2.tar.gz
New Actor::Base, Actor::Key and Actor::User
Diffstat (limited to 'lib/actor.rb')
-rw-r--r--lib/actor.rb18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/actor.rb b/lib/actor.rb
new file mode 100644
index 0000000..eab1bc4
--- /dev/null
+++ b/lib/actor.rb
@@ -0,0 +1,18 @@
+require_relative 'actor/base'
+require_relative 'actor/key'
+require_relative 'actor/user'
+
+module Actor
+ class UnsupportedActorError < StandardError; end
+
+ def self.new_from(str, audit_usernames: false)
+ case str
+ when Key.id_regex
+ Key.from(str, audit_usernames: audit_usernames)
+ when User.id_regex
+ User.from(str, audit_usernames: audit_usernames)
+ else
+ raise UnsupportedActorError
+ end
+ end
+end