Class: Scorecard::Cleaner

Inherits:
Object
  • Object
show all
Defined in:
lib/scorecard/cleaner.rb

Class Method Summary collapse

Class Method Details

.points(gameable_or_type, gameable_id = nil) ⇒ Object



2
3
4
5
6
7
8
9
10
11
# File 'lib/scorecard/cleaner.rb', line 2

def self.points(gameable_or_type, gameable_id = nil)
  points = gameable_id.nil? ?
    Scorecard::Point.for_gameable(gameable_or_type) :
    Scorecard::Point.for_raw_gameable(gameable_or_type, gameable_id)

  points.each do |point|
    point.destroy
    ActiveSupport::Notifications.instrument 'scorecard', user: point.user
  end
end

.points_async(gameable) ⇒ Object



13
14
15
16
# File 'lib/scorecard/cleaner.rb', line 13

def self.points_async(gameable)
  Scorecard::ClearWorker.perform_in 10.seconds, gameable.class.name,
    gameable.id
end