Module: WithProgress

Included in:
Content
Defined in:
app/models/concerns/with_progress.rb

Instance Method Summary collapse

Instance Method Details

#completed_for?(user, organization) ⇒ Boolean

Returns:

  • (Boolean)


26
27
28
# File 'app/models/concerns/with_progress.rb', line 26

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



18
19
20
21
22
23
24
# File 'app/models/concerns/with_progress.rb', line 18

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



14
15
16
# File 'app/models/concerns/with_progress.rb', line 14

def dirty_progresses!
  Indicator.dirty_by_content_change! self
end

#has_progress_for?(user, organization) ⇒ Boolean

Returns:

  • (Boolean)


10
11
12
# File 'app/models/concerns/with_progress.rb', line 10

def has_progress_for?(user, organization)
  progress_for(user, organization).persisted?
end

#once_completed_for?(user, organization) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
# File 'app/models/concerns/with_progress.rb', line 30

def once_completed_for?(user, organization)
  progress_for(user, organization).once_completed?
end

#progress_for(user, organization) ⇒ Object



2
3
4
# File 'app/models/concerns/with_progress.rb', line 2

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