Sha256: 87abbc807eb5b89debab2d6e731aa65431b5e9d2cade42a2c5d3f543b4f871b6
Contents?: true
Size: 746 Bytes
Versions: 3
Compression:
Stored size: 746 Bytes
Contents
module GoGamification::Concerns::Models::Reward extend ActiveSupport::Concern included do belongs_to :goal, class_name: 'GoGamification::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
3 entries across 3 versions & 1 rubygems