Class: Organization::Status::Base

Inherits:
Object
  • Object
show all
Defined in:
app/models/concerns/organization/status/base.rb

Direct Known Subclasses

Disabled, Enabled, InPreparation

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(organization) ⇒ Base

Returns a new instance of Base.



7
8
9
# File 'app/models/concerns/organization/status/base.rb', line 7

def initialize(organization)
  @organization = organization
end

Instance Attribute Details

#organizationObject (readonly)

Returns the value of attribute organization.



3
4
5
# File 'app/models/concerns/organization/status/base.rb', line 3

def organization
  @organization
end

Instance Method Details

#access_mode(user) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'app/models/concerns/organization/status/base.rb', line 11

def access_mode(user)
  if user&.teacher_of? organization
    teacher_access_mode(user)
  elsif user&.student_of? organization
    student_access_mode(user)
  elsif user&.ex_student_of? organization
    ex_student_access_mode(user)
  else
    outsider_access_mode(user)
  end
end

#validate!(user = nil) ⇒ Object



23
24
25
# File 'app/models/concerns/organization/status/base.rb', line 23

def validate!(user = nil)
  validate_enabled! unless user
end