Module: SiblingsNavigation

Included in:
Chapter, Exercise, Lesson
Defined in:
app/models/concerns/navigation/siblings_navigation.rb

Instance Method Summary collapse

Instance Method Details

Names



21
22
23
# File 'app/models/concerns/navigation/siblings_navigation.rb', line 21

def navigable_name
  "#{number}. #{name}"
end

#next_for(user) ⇒ Object



3
4
5
# File 'app/models/concerns/navigation/siblings_navigation.rb', line 3

def next_for(user)
  user.pending_siblings_at(self).select { |it| it.number > number }.sort_by(&:number).first
end

#pending_siblings_for(user, organization = Organization.current) ⇒ Object



15
16
17
# File 'app/models/concerns/navigation/siblings_navigation.rb', line 15

def pending_siblings_for(user, organization=Organization.current)
  siblings.reject { |it| it.progress_for(user, organization).completed? }
end

#restart(user) ⇒ Object



7
8
9
# File 'app/models/concerns/navigation/siblings_navigation.rb', line 7

def restart(user)
  user.pending_siblings_at(self).sort_by(&:number).first
end

#siblingsObject



11
12
13
# File 'app/models/concerns/navigation/siblings_navigation.rb', line 11

def siblings
  structural_parent.structural_children
end