Sha256: 0cf43fa7e3d2eb0581742577ea4d99f0b594135959fb0383ad4d1b3f421c1760

Contents?: true

Size: 767 Bytes

Versions: 14

Compression:

Stored size: 767 Bytes

Contents

module WithProgress
  def progress_for(user, organization)
    Indicator.find_or_initialize_by(user: user, organization: organization, content: self)
  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

  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 & 2 rubygems

Version Path
mumuki-laboratory-7.5.2 vendor/bundle/ruby/2.6.0/bundler/gems/mumuki-domain-ad16a5930cec/app/models/concerns/with_progress.rb
mumuki-laboratory-7.5.1 vendor/bundle/ruby/2.3.0/bundler/gems/mumuki-domain-a059418e5fd8/app/models/concerns/with_progress.rb
mumuki-domain-7.5.1 app/models/concerns/with_progress.rb
mumuki-laboratory-7.5.0 vendor/bundle/ruby/2.6.0/bundler/gems/mumuki-domain-acb12583b793/app/models/concerns/with_progress.rb
mumuki-domain-7.5.0 app/models/concerns/with_progress.rb
mumuki-domain-7.4.1 app/models/concerns/with_progress.rb
mumuki-domain-7.4.0 app/models/concerns/with_progress.rb
mumuki-domain-7.3.2 app/models/concerns/with_progress.rb
mumuki-domain-7.3.1 app/models/concerns/with_progress.rb
mumuki-domain-7.2.3 app/models/concerns/with_progress.rb
mumuki-domain-7.3.0 app/models/concerns/with_progress.rb
mumuki-domain-7.2.2 app/models/concerns/with_progress.rb
mumuki-domain-7.2.1 app/models/concerns/with_progress.rb
mumuki-domain-7.2.0 app/models/concerns/with_progress.rb