Sha256: 570eaf61024d3711ab38f7aa400f698bf143dfe7b599c6e6ff1efc59106967d4

Contents?: true

Size: 572 Bytes

Versions: 27

Compression:

Stored size: 572 Bytes

Contents

module WithDiscussions
  extend ActiveSupport::Concern

  included do
    has_many :discussions, as: :item, dependent: :delete_all
  end

  def discuss!(user, discussion)
    discussion.merge!(initiator_id: user.id)
    discussion.merge!(submission: submission_for(user)) if submission_for(user).present?
    created_discussion = discussions.create discussion
    user.subscribe_to! created_discussion
    created_discussion
  end

  def submission_for(_)
    nil
  end

  def try_solve_discussions(user)
    discussions.where(initiator: user).map(&:try_solve!)
  end
end

Version data entries

27 entries across 27 versions & 2 rubygems

Version Path
mumuki-domain-6.4.3 app/models/concerns/with_discussions.rb
mumuki-domain-6.4.2 app/models/concerns/with_discussions.rb
mumuki-domain-6.4.1 app/models/concerns/with_discussions.rb
mumuki-domain-6.4.0 app/models/concerns/with_discussions.rb
mumuki-domain-6.2.2 app/models/concerns/with_discussions.rb
mumuki-domain-6.2.1 app/models/concerns/with_discussions.rb
mumuki-domain-6.3.0 app/models/concerns/with_discussions.rb
mumuki-domain-6.2.0 app/models/concerns/with_discussions.rb
mumuki-domain-6.1.5 app/models/concerns/with_discussions.rb
mumuki-domain-6.0.4 app/models/concerns/with_discussions.rb
mumuki-domain-6.1.4 app/models/concerns/with_discussions.rb
mumuki-domain-6.1.3 app/models/concerns/with_discussions.rb
mumuki-domain-6.1.2 app/models/concerns/with_discussions.rb
mumuki-domain-6.0.3 app/models/concerns/with_discussions.rb
mumuki-domain-6.0.1 app/models/concerns/with_discussions.rb
mumuki-domain-6.0.0 app/models/concerns/with_discussions.rb
mumuki-laboratory-5.13.0 app/models/concerns/with_discussions.rb
mumuki-laboratory-5.12.1 app/models/concerns/with_discussions.rb
mumuki-laboratory-5.12.0 app/models/concerns/with_discussions.rb
mumuki-laboratory-5.11.0 app/models/concerns/with_discussions.rb