Sha256: 5860dc0e3a27c051ba30d828a02d08a25db80e4df7a0f78339f1f0ebdcb6faf4

Contents?: true

Size: 813 Bytes

Versions: 10

Compression:

Stored size: 813 Bytes

Contents

module WithProgress
  def progress_for(user, organization)
    user.progress_at(self, organization)
  end

  def completion_percentage_for(user, organization=Organization.current)
    progress_for(user, organization).completion_percentage
  end

  def dirty_progresses!
    Indicator.dirty_by_content_change! self
  end

  def dirty_progress_if_structural_children_changed!
    old_structural_children = structural_children.to_a
    yield
    Indicator.dirty_by_content_change! self if structural_children_changed?(old_structural_children)

    self
  end

  def completed_for?(user, organization)
    progress_for(user, organization).completed?
  end

  private

  def structural_children_changed?(old_structural_children)
    (Set.new(structural_children) ^ Set.new(old_structural_children)).present?
  end
end

Version data entries

10 entries across 10 versions & 2 rubygems

Version Path
mumuki-domain-7.10.1 app/models/concerns/with_progress.rb
mumuki-domain-7.10.0 app/models/concerns/with_progress.rb
mumuki-laboratory-7.9.2 vendor/bundle/ruby/2.6.0/bundler/gems/mumuki-domain-7082a83493eb/app/models/concerns/with_progress.rb
mumuki-domain-7.9.2 app/models/concerns/with_progress.rb
mumuki-laboratory-7.9.1 vendor/bundle/ruby/2.6.0/bundler/gems/mumuki-domain-b162dc91aa77/app/models/concerns/with_progress.rb
mumuki-domain-7.9.1 app/models/concerns/with_progress.rb
mumuki-laboratory-7.9.0 vendor/bundle/ruby/2.6.0/bundler/gems/mumuki-domain-520f859ca8af/app/models/concerns/with_progress.rb
mumuki-domain-7.9.0 app/models/concerns/with_progress.rb
mumuki-domain-7.8.1 app/models/concerns/with_progress.rb
mumuki-domain-7.8.0 app/models/concerns/with_progress.rb