Sha256: 3be37841557203d27ec8f0c64d813c07506cb3e7a4b1345b8242ae1a50f2a1c3

Contents?: true

Size: 662 Bytes

Versions: 33

Compression:

Stored size: 662 Bytes

Contents

module WithDiscussions
  extend ActiveSupport::Concern

  included do
    has_many :discussions, as: :item, dependent: :destroy
    organic_on :discussions
  end

  def discuss!(user, discussion, organization = Organization.current)
    discussion.merge!(initiator_id: user.id, organization: organization)
    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

33 entries across 33 versions & 2 rubygems

Version Path
mumuki-domain-7.6.1 app/models/concerns/with_discussions.rb
mumuki-domain-7.6.0 app/models/concerns/with_discussions.rb
mumuki-laboratory-7.5.2 vendor/bundle/ruby/2.6.0/bundler/gems/mumuki-domain-ad16a5930cec/app/models/concerns/with_discussions.rb
mumuki-laboratory-7.5.1 vendor/bundle/ruby/2.3.0/bundler/gems/mumuki-domain-a059418e5fd8/app/models/concerns/with_discussions.rb
mumuki-domain-7.5.1 app/models/concerns/with_discussions.rb
mumuki-laboratory-7.5.0 vendor/bundle/ruby/2.6.0/bundler/gems/mumuki-domain-acb12583b793/app/models/concerns/with_discussions.rb
mumuki-domain-7.5.0 app/models/concerns/with_discussions.rb
mumuki-domain-7.4.1 app/models/concerns/with_discussions.rb
mumuki-domain-7.4.0 app/models/concerns/with_discussions.rb
mumuki-domain-7.3.2 app/models/concerns/with_discussions.rb
mumuki-domain-7.3.1 app/models/concerns/with_discussions.rb
mumuki-domain-7.2.3 app/models/concerns/with_discussions.rb
mumuki-domain-7.3.0 app/models/concerns/with_discussions.rb
mumuki-domain-7.2.2 app/models/concerns/with_discussions.rb
mumuki-domain-7.2.1 app/models/concerns/with_discussions.rb
mumuki-domain-7.2.0 app/models/concerns/with_discussions.rb
mumuki-laboratory-7.1.0 vendor/bundle/ruby/2.3.0/bundler/gems/mumuki-domain-925adf85cca8/app/models/concerns/with_discussions.rb
mumuki-domain-7.1.0 app/models/concerns/with_discussions.rb
mumuki-laboratory-7.0.12 vendor/bundle/ruby/2.3.0/bundler/gems/mumuki-domain-74da3d4af98c/app/models/concerns/with_discussions.rb
mumuki-domain-7.0.6 app/models/concerns/with_discussions.rb