mirror of
https://github.com/discourse/discourse.git
synced 2024-11-24 00:51:03 +08:00
22 lines
489 B
Ruby
22 lines
489 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
|