Skip to content

Instantly share code, notes, and snippets.

@brynary
Created January 30, 2013 03:36
Show Gist options
  • Save brynary/4670393 to your computer and use it in GitHub Desktop.
Save brynary/4670393 to your computer and use it in GitHub Desktop.
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