Class: RewardCpt::Operations::GivingOperation
- Inherits:
-
Trailblazer::Operation
- Object
- Trailblazer::Operation
- RewardCpt::Operations::GivingOperation
- Extended by:
- Contract::DSL
- Defined in:
- app/concepts/reward_cpt/operations/giving_operation.rb
Overview
Operation class to check whether given code is a another user referral code
Instance Method Summary collapse
Instance Method Details
#find_user!(options) ⇒ Object
21 22 23 24 25 |
# File 'app/concepts/reward_cpt/operations/giving_operation.rb', line 21 def find_user!(, *) ['user'] = User.find ['params']['user_id'] rescue ActiveRecord::RecordNotFound false end |
#give_reward!(options) ⇒ Object
27 28 29 30 31 32 33 34 35 36 |
# File 'app/concepts/reward_cpt/operations/giving_operation.rb', line 27 def give_reward!(, *) user = ['user'] reward = Reward.new user_id: user.id, points_total: ['params']['amount'], points_pending: 0, description: ['params']['description'], redeemed: false, country_id: user.country_id reward.save end |