Class: Booth::Models::Contests::Scopes::RecentlyCreated

Inherits:
Object
  • Object
show all
Includes:
Booth::MethodObject
Defined in:
lib/booth/models/contests/scopes/recently_created.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
# File 'lib/booth/models/contests/scopes/recently_created.rb', line 10

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

Instance Method Details

#callObject



15
16
17
18
# File 'lib/booth/models/contests/scopes/recently_created.rb', line 15

def call
  contest.created_at.present? &&
    contest.created_at > ::Booth::Models::Contest.lifespan.ago
end