Sha256: b7c83d34a699236a30feb76b34ab518a4cde18dfb4b1881bab0bbba49b3d26c8

Contents?: true

Size: 1018 Bytes

Versions: 14

Compression:

Stored size: 1018 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 has_progress_for?(user, organization)
    progress_for(user, organization).persisted?
  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

14 entries across 14 versions & 1 rubygems

Version Path
mumuki-domain-9.23.0 app/models/concerns/with_progress.rb
mumuki-domain-9.22.1 app/models/concerns/with_progress.rb
mumuki-domain-9.22.0 app/models/concerns/with_progress.rb
mumuki-domain-9.21.0 app/models/concerns/with_progress.rb
mumuki-domain-9.20.0 app/models/concerns/with_progress.rb
mumuki-domain-9.19.0 app/models/concerns/with_progress.rb
mumuki-domain-9.18.0 app/models/concerns/with_progress.rb
mumuki-domain-9.17.0 app/models/concerns/with_progress.rb
mumuki-domain-9.16.0 app/models/concerns/with_progress.rb
mumuki-domain-9.15.0 app/models/concerns/with_progress.rb
mumuki-domain-9.14.1 app/models/concerns/with_progress.rb
mumuki-domain-9.14.0 app/models/concerns/with_progress.rb
mumuki-domain-9.13.1 app/models/concerns/with_progress.rb
mumuki-domain-9.13.0 app/models/concerns/with_progress.rb