diff options
author | http://jneen.net/ <jneen@jneen.net> | 2017-03-08 06:06:13 +0300 |
---|---|---|
committer | http://jneen.net/ <jneen@jneen.net> | 2017-03-09 23:02:49 +0300 |
commit | ef4ba8d3ce32d4e8af34ac86b64e5cf7a85ed926 (patch) | |
tree | d50dca2d85e6462fb6e21b7ca50ea709a22b6cd3 | |
parent | b88314f4ad955897dc737b6e9515b43dc9d97422 (diff) |
add .internal and .non_internal scopes
-rw-r--r-- | app/models/user.rb | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/app/models/user.rb b/app/models/user.rb index 520baf6e659..1081f103ea6 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -354,8 +354,20 @@ class User < ActiveRecord::Base end end + def self.internal_attributes + [:ghost] + end + def internal? - ghost? + self.class.internal_attributes.any? { |a| self[a] } + end + + def self.internal + where(Hash[internal_attributes.zip([true] * internal_attributes.size)]) + end + + def self.non_internal + where(Hash[internal_attributes.zip([false] * internal_attributes.size)]) end # |