mirror of
https://github.com/discourse/discourse.git
synced 2024-11-26 00:43:39 +08:00
28 lines
555 B
Ruby
28 lines
555 B
Ruby
# frozen_string_literal: true
|
|
|
|
class ApiKeyScopeSerializer < ApplicationSerializer
|
|
|
|
attributes :resource,
|
|
:action,
|
|
:parameters,
|
|
:urls,
|
|
:allowed_parameters,
|
|
:key
|
|
|
|
def parameters
|
|
ApiKeyScope.scope_mappings.dig(object.resource.to_sym, object.action.to_sym, :params).to_a
|
|
end
|
|
|
|
def urls
|
|
ApiKeyScope.scope_mappings.dig(object.resource.to_sym, object.action.to_sym, :urls).to_a
|
|
end
|
|
|
|
def action
|
|
object.action.to_s.gsub('_', ' ')
|
|
end
|
|
|
|
def key
|
|
object.action
|
|
end
|
|
end
|