Class: Mumuki::Domain::Workspace

Inherits:
Object
  • Object
show all
Defined in:
lib/mumuki/domain/workspace.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, area) ⇒ Workspace

area is a organization-like or course-like object that can be converted into slugs, has content and access-rules information



6
7
8
9
# File 'lib/mumuki/domain/workspace.rb', line 6

def initialize(user, area)
  @user = user
  @area = area
end

Instance Attribute Details

#areaObject

Returns the value of attribute area.



2
3
4
# File 'lib/mumuki/domain/workspace.rb', line 2

def area
  @area
end

#userObject

Returns the value of attribute user.



2
3
4
# File 'lib/mumuki/domain/workspace.rb', line 2

def user
  @user
end

Instance Method Details

#annonymous?Boolean

Returns:

  • (Boolean)


11
12
13
# File 'lib/mumuki/domain/workspace.rb', line 11

def annonymous?
  user.nil?
end

#enabled_containers(sequence) ⇒ Object

Takes a didactic sequence of containers and retuns the enabled containers for this user in this workspace.

This method does not check the user is actually member of the area, you should check that before sending this message



25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/mumuki/domain/workspace.rb', line 25

def enabled_containers(sequence)
  return sequence if annonymous? || teacher?

  # TODO refactor when introducing access rules
  if area.progressive_display_lookahead
    user.completed_containers_with_lookahead(
      sequence,
      area.to_organization,
      lookahead: area.progressive_display_lookahead)
  else
    sequence
  end
end

#teacher?Boolean

Returns:

  • (Boolean)


15
16
17
# File 'lib/mumuki/domain/workspace.rb', line 15

def teacher?
  user.teacher_of? area
end