summaryrefslogtreecommitdiff
path: root/app/models/user.rb
diff options
context:
space:
mode:
authornfoy <nfoy@purdue.edu>2014-04-03 16:49:07 -0400
committernfoy <nfoy@purdue.edu>2014-04-03 16:49:07 -0400
commitef0cc1035632d7b59a5977038ac30fe1292d0128 (patch)
treecc4b6f1105defaa7ac56afa141d2416a7f956f9d /app/models/user.rb
parent9d2e1394bc09d4df3fce97d6151f5bfc3546fbe8 (diff)
parentd6009eddd6f67a9414ff7d707ae82c053e6653ad (diff)
Merge branch 'master' of https://github.com/LukeShu/leaguer
Diffstat (limited to 'app/models/user.rb')
-rw-r--r--app/models/user.rb15
1 files changed, 15 insertions, 0 deletions
diff --git a/app/models/user.rb b/app/models/user.rb
index 277d885..016c155 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -91,3 +91,18 @@ class User < ActiveRecord::Base
validates :password, length: { minimum: 6 }
end
+class NilUser
+ def nil?
+ return true
+ end
+ def can?(action)
+ return false
+ end
+ def method_missing(name, *args)
+ # Throw an error if User doesn't have this method
+ super unless User.new.respond_to?(name)
+ # User has this method -- return a blank value
+ # 'false' if the method ends with '?'; 'nil' otherwise.
+ name.ends_with?('?') ? false : nil
+ end
+end