Class: Stepped::Achievement

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/stepped/achievement.rb

Defined Under Namespace

Classes: ExistsError

Class Method Summary collapse

Class Method Details

.erase_of(action) ⇒ Object



19
20
21
# File 'app/models/stepped/achievement.rb', line 19

def erase_of(action)
  where(action.attributes.slice("checksum_key")).destroy_all
end

.exists_for?(action) ⇒ Boolean

Returns:

  • (Boolean)


3
4
5
6
7
# File 'app/models/stepped/achievement.rb', line 3

def exists_for?(action)
  return false if action.checksum.nil?

  exists? action.attributes.slice("checksum_key", "checksum")
end

.grand_to(action) ⇒ Object



15
16
17
# File 'app/models/stepped/achievement.rb', line 15

def grand_to(action)
  create! action.attributes.slice("checksum_key", "checksum")
end

.raise_if_exists_for?(action) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
12
13
# File 'app/models/stepped/achievement.rb', line 9

def raise_if_exists_for?(action)
  if exists_for?(action)
    raise ExistsError
  end
end