Sha256: d3f5fdab674c123f666a4f24e22fb54a32ccd55c32c8c9825fdd289d451331fe

Contents?: true

Size: 605 Bytes

Versions: 14

Compression:

Stored size: 605 Bytes

Contents

module Merit
  class Score < ActiveRecord::Base
    self.table_name = :merit_scores
    belongs_to :sash
    has_many :score_points,
             dependent: :destroy,
             class_name: 'Merit::Score::Point'

    def points
      score_points.group(:score_id).sum(:num_points).values.first || 0
    end

    class Point < ActiveRecord::Base
      belongs_to :score, class_name: 'Merit::Score'
      has_one :sash, through: :score
      has_many :activity_logs,
               class_name: 'Merit::ActivityLog',
               as: :related_change
      delegate :sash_id, to: :score
    end
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
merit-3.0.3 lib/merit/models/active_record/merit/score.rb
merit-3.0.2 lib/merit/models/active_record/merit/score.rb
merit-3.0.1 lib/merit/models/active_record/merit/score.rb
merit-3.0.0 lib/merit/models/active_record/merit/score.rb
merit-2.4.0 lib/merit/models/active_record/merit/score.rb
merit-2.3.4 lib/merit/models/active_record/merit/score.rb
merit-2.3.3 lib/merit/models/active_record/merit/score.rb
merit-2.3.2 lib/merit/models/active_record/merit/score.rb
merit-2.3.1 lib/merit/models/active_record/merit/score.rb
merit-2.3.0 lib/merit/models/active_record/merit/score.rb
merit-2.2.0 lib/merit/models/active_record/merit/score.rb
merit-2.1.2 lib/merit/models/active_record/merit/score.rb
merit-2.1.1 lib/merit/models/active_record/merit/score.rb
merit-2.1.0 lib/merit/models/active_record/merit/score.rb