Module: Recognition::Models::Gift
- Includes:
- Redeemable
- Defined in:
- lib/recognition/models/gift.rb
Instance Method Summary
collapse
Methods included from Redeemable
#bucket, #expired?, #get_user_counter, #is_redeemable?, #redeem, #regenerate_code, #transactions
Instance Method Details
#execute_redemption(id) ⇒ Object
21
22
23
24
|
# File 'lib/recognition/models/gift.rb', line 21
def execute_redemption id
actual_amount = (self.amount.to_i * -1)
Recognition::Database.redeem id, bucket, self.class.to_s.downcase, self.code, actual_amount
end
|
#redeemable?(recognizable) ⇒ Boolean
8
9
10
11
12
13
14
15
16
17
18
19
|
# File 'lib/recognition/models/gift.rb', line 8
def redeemable? recognizable
pass = false
if recognizable.points >= self.amount
if is_redeemable?(recognizable)
pass = true
end
else
errors.add(:base, "#{self.class.to_s} can not be redeemed: insufficient points")
pass = false
end
pass
end
|