Class: CommandTower::Configuration::AdminScope::ToolRegistration

Inherits:
Object
  • Object
show all
Defined in:
lib/command_tower/configuration/admin_scope/tool_registration.rb

Constant Summary collapse

BASE_HOOKS =
%i[options validate availability].freeze
RESOURCE_NARROWING_HOOKS =
%i[narrow_users narrow_audit affected_users_in_scope].freeze
RESOURCE_SCOPED_TOOL_IDS =
%w[users audit].freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#affected_users_in_scopeObject

Returns the value of attribute affected_users_in_scope.



11
12
13
# File 'lib/command_tower/configuration/admin_scope/tool_registration.rb', line 11

def affected_users_in_scope
  @affected_users_in_scope
end

#availabilityObject

Returns the value of attribute availability.



11
12
13
# File 'lib/command_tower/configuration/admin_scope/tool_registration.rb', line 11

def availability
  @availability
end

#host_context_typeObject

Returns the value of attribute host_context_type.



11
12
13
# File 'lib/command_tower/configuration/admin_scope/tool_registration.rb', line 11

def host_context_type
  @host_context_type
end

#narrow_auditObject

Returns the value of attribute narrow_audit.



11
12
13
# File 'lib/command_tower/configuration/admin_scope/tool_registration.rb', line 11

def narrow_audit
  @narrow_audit
end

#narrow_usersObject

Returns the value of attribute narrow_users.



11
12
13
# File 'lib/command_tower/configuration/admin_scope/tool_registration.rb', line 11

def narrow_users
  @narrow_users
end

#optionsObject

Returns the value of attribute options.



11
12
13
# File 'lib/command_tower/configuration/admin_scope/tool_registration.rb', line 11

def options
  @options
end

#validateObject

Returns the value of attribute validate.



11
12
13
# File 'lib/command_tower/configuration/admin_scope/tool_registration.rb', line 11

def validate
  @validate
end

Instance Method Details

#validate!(tool_id:) ⇒ Object



14
15
16
17
18
19
20
# File 'lib/command_tower/configuration/admin_scope/tool_registration.rb', line 14

def validate!(tool_id:)
  missing = required_hooks_for(tool_id).reject { |hook| callable?(public_send(hook)) }
  return self if missing.empty?

  raise CommandTower::AdminScope::InvalidToolRegistrationError,
    "admin scope registration for #{tool_id} is missing hooks: #{missing.join(", ")}"
end