2023-12-07 16:42:56 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2024-01-04 08:44:07 -05:00
|
|
|
class AiToolSerializer < ApplicationSerializer
|
2023-12-07 16:42:56 -05:00
|
|
|
attributes :options, :id, :name, :help
|
|
|
|
|
|
|
|
def include_options?
|
2024-01-04 08:44:07 -05:00
|
|
|
object.accepted_options.present?
|
2023-12-07 16:42:56 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
def id
|
|
|
|
object.to_s.split("::").last
|
|
|
|
end
|
|
|
|
|
|
|
|
def name
|
|
|
|
object.name.humanize.titleize
|
|
|
|
end
|
|
|
|
|
|
|
|
def help
|
|
|
|
object.help
|
|
|
|
end
|
|
|
|
|
|
|
|
def options
|
|
|
|
options = {}
|
2024-01-04 08:44:07 -05:00
|
|
|
object.accepted_options.each do |option|
|
2023-12-07 16:42:56 -05:00
|
|
|
options[option.name] = {
|
|
|
|
name: option.localized_name,
|
|
|
|
description: option.localized_description,
|
|
|
|
type: option.type,
|
|
|
|
}
|
|
|
|
end
|
|
|
|
options
|
|
|
|
end
|
|
|
|
end
|