Sha256: d391bccdc8ddea42d07e82ffee3dd49545a6c5bf295953ecafb41d8f4443faf7

Contents?: true

Size: 919 Bytes

Versions: 40

Compression:

Stored size: 919 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

  def once_completed_for?(user, organization)
    progress_for(user, organization).once_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

40 entries across 40 versions & 2 rubygems

Version Path
mumuki-domain-9.0.2 app/models/concerns/with_progress.rb
mumuki-domain-9.0.0 app/models/concerns/with_progress.rb
mumuki-domain-8.6.1 app/models/concerns/with_progress.rb
mumuki-domain-8.6.0 app/models/concerns/with_progress.rb
mumuki-domain-8.5.0 app/models/concerns/with_progress.rb
mumuki-domain-8.4.0 app/models/concerns/with_progress.rb
mumuki-domain-8.3.1 app/models/concerns/with_progress.rb
mumuki-domain-8.2.0 app/models/concerns/with_progress.rb
mumuki-domain-8.1.3 app/models/concerns/with_progress.rb
mumuki-domain-8.1.2 app/models/concerns/with_progress.rb
mumuki-domain-8.1.1 app/models/concerns/with_progress.rb
mumuki-domain-8.1.0 app/models/concerns/with_progress.rb
mumuki-domain-8.0.0 app/models/concerns/with_progress.rb
mumuki-domain-7.12.2 app/models/concerns/with_progress.rb
mumuki-domain-7.12.1 app/models/concerns/with_progress.rb
mumuki-domain-7.12.0 app/models/concerns/with_progress.rb
mumuki-domain-7.11.1 app/models/concerns/with_progress.rb
mumuki-laboratory-7.11.1 vendor/bundle/ruby/2.6.0/bundler/gems/mumuki-domain-c92f2a7212e2/app/models/concerns/with_progress.rb
mumuki-laboratory-7.11.0 vendor/bundle/ruby/2.6.0/bundler/gems/mumuki-domain-2e15c3330133/app/models/concerns/with_progress.rb
mumuki-domain-7.11.0 app/models/concerns/with_progress.rb