Class: Booth::Models::Contests::Scopes::RecentlyResponded

Inherits:
Object
  • Object
show all
Includes:
Booth::MethodObject
Defined in:
lib/booth/models/contests/scopes/recently_responded.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Booth::MethodObject

included

Class Method Details

.scope(base) ⇒ Object



10
11
12
13
14
# File 'lib/booth/models/contests/scopes/recently_responded.rb', line 10

def self.scope(base)
  base.where.not(created_at: nil, responded_at: nil)
      .where('created_at > ?', lifespan.ago)
      .where('responded_at > ?', lifespan.ago)
end

Instance Method Details

#callObject



16
17
18
19
20
21
# File 'lib/booth/models/contests/scopes/recently_responded.rb', line 16

def call
  contest.created_at.present? &&
    contest.responded_at.present? &&
    contest.created_at > lifespan.ago &&
    contest.responded_at > lifespan.ago
end