Class: Hyrax::EditPermissionsService::PermissionPresenter Private

Inherits:
Object
  • Object
show all
Defined in:
app/services/hyrax/edit_permissions_service.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

A helper class to contain specific presentation logic related to the Hyrax::EditPermissionsService

Instance Method Summary collapse

Constructor Details

#initialize(service:, permission_hash:) ⇒ PermissionPresenter

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of PermissionPresenter.

Parameters:


95
96
97
98
# File 'app/services/hyrax/edit_permissions_service.rb', line 95

def initialize(service:, permission_hash:)
  @service = service
  @permission_hash = permission_hash
end

Instance Method Details

#accessObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns String.

Returns:

  • String


120
121
122
# File 'app/services/hyrax/edit_permissions_service.rb', line 120

def access
  @permission_hash.fetch(:access)
end

#can_edit?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns Boolean.

Returns:

  • (Boolean)

    Boolean

See Also:


126
127
128
# File 'app/services/hyrax/edit_permissions_service.rb', line 126

def can_edit?
  !@service.cannot_edit_permissions?(@permission_hash)
end

#granted_by_html_hintObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

A hint at how permissions are granted.

rubocop:disable Rails/OutputSafety

Returns:

  • String


104
105
106
107
108
109
110
111
# File 'app/services/hyrax/edit_permissions_service.rb', line 104

def granted_by_html_hint
  html = ""
  @service.unauthorized_collection_managers.each do |managers|
    next unless name == managers.fetch(:name)
    html += "<br />Access granted via collection #{managers.fetch(:id)}"
  end
  html.html_safe
end

#nameObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns String.

Returns:

  • String


115
116
117
# File 'app/services/hyrax/edit_permissions_service.rb', line 115

def name
  @permission_hash.fetch(:name)
end