Module: Referable
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/referable.rb,
lib/referable/version.rb,
lib/generators/referable/templates/concerns/referable.rb
Constant Summary collapse
- VERSION =
'0.3.0'
Instance Method Summary collapse
- #acquired_reward! ⇒ Object
- #distance_to_next_reward ⇒ Object
- #increment!(attribute, by = 1) ⇒ Object
- #percent_to_next_reward ⇒ Object
Instance Method Details
#acquired_reward! ⇒ Object
29 30 31 |
# File 'lib/generators/referable/templates/concerns/referable.rb', line 29 def acquired_reward! update!(last_reward_acquired: last_reward_acquired.next_reward(above: referrals.size)) end |
#distance_to_next_reward ⇒ Object
23 24 25 26 27 |
# File 'lib/generators/referable/templates/concerns/referable.rb', line 23 def distance_to_next_reward last_reward_acquired .next_reward(above: referrals.size) .referrals_required - referrals.size end |
#increment!(attribute, by = 1) ⇒ Object
33 34 35 36 |
# File 'lib/generators/referable/templates/concerns/referable.rb', line 33 def increment!(attribute, by = 1) super check_for_new_reward end |
#percent_to_next_reward ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/generators/referable/templates/concerns/referable.rb', line 14 def percent_to_next_reward last_tier_count = last_reward_acquired.referrals_required next_tier_count = last_reward_acquired .next_reward(above: referrals.size) .referrals_required - last_tier_count current_count = referrals.size - last_tier_count (current_count.to_f / next_tier_count) * 100 end |