Created
January 30, 2013 03:36
-
-
Save brynary/4670393 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ActiveUserPolicy | |
LOGIN_PERIOD = 14.days | |
class Query | |
def initialize(relation = User.scoped) | |
@relation = relation | |
end | |
def find_each(&block) | |
@relation. | |
where(email_confirmed: true). | |
where('last_login < ?', LOGIN_PERIOD.ago). | |
find_each(&block) | |
end | |
end | |
def initialize(user) | |
@user = user | |
end | |
def active? | |
@user.email_confirmed? && | |
@user.last_login_at < LOGIN_PERIOD.ago | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment