Class: OrganizationAccessMode::Base

Inherits:
Object
  • Object
show all
Defined in:
app/models/organization_access_mode/base.rb

Direct Known Subclasses

Forbidden, Full, ReadOnly

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, organization) ⇒ Base

Returns a new instance of Base.



4
5
6
7
# File 'app/models/organization_access_mode/base.rb', line 4

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

Instance Attribute Details

#organizationObject (readonly)

Returns the value of attribute organization.



2
3
4
# File 'app/models/organization_access_mode/base.rb', line 2

def organization
  @organization
end

#userObject (readonly)

Returns the value of attribute user.



2
3
4
# File 'app/models/organization_access_mode/base.rb', line 2

def user
  @user
end

Instance Method Details

#discuss_here?Boolean

Returns:

  • (Boolean)


24
25
26
27
28
# File 'app/models/organization_access_mode/base.rb', line 24

def discuss_here?
  organization.forum_enabled? && user.discusser_of?(organization) &&
    user.trusted_as_discusser_in?(organization) && !user.banned_from_forum? &&
    !user.currently_in_exam?
end

#faqs_here?Boolean

Returns:

  • (Boolean)


12
13
14
# File 'app/models/organization_access_mode/base.rb', line 12

def faqs_here?
  organization.faqs.present?
end

#read_only?Boolean

Returns:

  • (Boolean)


42
43
44
# File 'app/models/organization_access_mode/base.rb', line 42

def read_only?
  false
end

#resolve_discussions_here?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'app/models/organization_access_mode/base.rb', line 20

def resolve_discussions_here?
  false
end

#restore_indicators?(_content) ⇒ Boolean

Returns:

  • (Boolean)


38
39
40
# File 'app/models/organization_access_mode/base.rb', line 38

def restore_indicators?(_content)
  false
end

#show_content_element?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'app/models/organization_access_mode/base.rb', line 34

def show_content_element?
  false
end

#show_discussion_element?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'app/models/organization_access_mode/base.rb', line 30

def show_discussion_element?
  false
end

#submit_solutions_here?Boolean

Returns:

  • (Boolean)


16
17
18
# File 'app/models/organization_access_mode/base.rb', line 16

def submit_solutions_here?
  false
end

#validate_active!Object



9
10
# File 'app/models/organization_access_mode/base.rb', line 9

def validate_active!
end

#validate_content_here!(content) ⇒ Object



50
51
52
# File 'app/models/organization_access_mode/base.rb', line 50

def validate_content_here!(content)
  raise Mumuki::Domain::ForbiddenError unless show_content?(content)
end

#validate_discuss_here!(_discussion) ⇒ Object



46
47
48
# File 'app/models/organization_access_mode/base.rb', line 46

def validate_discuss_here!(_discussion)
  raise Mumuki::Domain::ForbiddenError
end