Sha256: 1b6560b9ad6b48d1251d9e76e95f701e77fa65ce6af6eb47ea41ee14b168f074
Contents?: true
Size: 742 Bytes
Versions: 4
Compression:
Stored size: 742 Bytes
Contents
module Gamification::Concerns::Models::Reward extend ActiveSupport::Concern included do belongs_to :goal, class_name: 'Gamification::Goal' belongs_to :rewardable, polymorphic: true, inverse_of: :rewards scope :unseen, -> { where seen_at: nil } scope :seen, -> { where.not seen_at: nil } scope :with_medals, -> { all.select &:medal } scope :without_medals, -> { all.reject &:medal } validates :rewardable_id, uniqueness: { scope: [:rewardable_type, :goal] } delegate :points, to: :goal delegate :medal, to: :goal def see touch :seen_at end def seen? !!seen_at end class << self def see all.map { |reward| reward.see } end end end end
Version data entries
4 entries across 4 versions & 1 rubygems