def call(name:, limit: nil, offset: nil)
declaration = lookup_declaration(name)
case declaration
when Error
response(declaration)
when Rubydex::Namespace
page, total = paginate(declaration.descendants, offset, limit, 500)
descendants = page.map do |descendant|
{
name: descendant.name,
kind: declaration_kind(descendant),
}
end
response(name: declaration.name, descendants: descendants, total: total)
else
response(
Error.new(
"invalid_kind",
"'#{name}' is not a class or module (it is a #{declaration_kind(declaration)})",
"get_descendants only works on classes and modules, not methods or constants",
),
)
end
end