diff options
author | DavisLWebb <davislwebb@ymail.com> | 2014-04-03 17:56:24 -0400 |
---|---|---|
committer | DavisLWebb <davislwebb@ymail.com> | 2014-04-03 17:56:24 -0400 |
commit | 8b3fae332f81b42671bd2a4f332626c75fdeb976 (patch) | |
tree | 917b5d74695b69670a75f83f0ba3deeb83e44f07 /app/models/user.rb | |
parent | 6289593da4b6ad30c893b61caf4ac142b590710a (diff) | |
parent | 0c1583c0b31504dfdbbbec3e6dcc240acb059891 (diff) |
Merge branch 'master' of https://github.com/LukeShu/Leaguer
Diffstat (limited to 'app/models/user.rb')
-rw-r--r-- | app/models/user.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index 7c8ae84..9a0948f 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -93,3 +93,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 |