Module: WithProgress
- Included in:
- Content
- Defined in:
- app/models/concerns/with_progress.rb
Instance Method Summary collapse
- #completed_for?(user, organization) ⇒ Boolean
- #completion_percentage_for(user, organization = Organization.current) ⇒ Object
- #dirty_progress_if_structural_children_changed! ⇒ Object
- #dirty_progresses! ⇒ Object
- #progress_for(user, organization) ⇒ Object
Instance Method Details
#completed_for?(user, organization) ⇒ Boolean
22 23 24 |
# File 'app/models/concerns/with_progress.rb', line 22 def completed_for?(user, organization) progress_for(user, organization).completed? end |
#completion_percentage_for(user, organization = Organization.current) ⇒ Object
6 7 8 |
# File 'app/models/concerns/with_progress.rb', line 6 def completion_percentage_for(user, organization=Organization.current) progress_for(user, organization).completion_percentage end |
#dirty_progress_if_structural_children_changed! ⇒ Object
14 15 16 17 18 19 20 |
# File 'app/models/concerns/with_progress.rb', line 14 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 |
#dirty_progresses! ⇒ Object
10 11 12 |
# File 'app/models/concerns/with_progress.rb', line 10 def dirty_progresses! Indicator.dirty_by_content_change! self end |
#progress_for(user, organization) ⇒ Object
2 3 4 |
# File 'app/models/concerns/with_progress.rb', line 2 def progress_for(user, organization) Indicator.find_or_initialize_by(user: user, organization: organization, content: self) end |