search.rb 550 B

123456789101112131415
  1. # Copyright (C) 2012-2024 Zammad Foundation, https://zammad-foundation.org/
  2. class Service::ExternalDataSource::Search < Service::Base
  3. def execute(attribute:, render_context:, term:, limit: 10)
  4. @attribute = attribute
  5. ExternalDataSource.new(options: attribute.data_option, render_context:, term:, limit:).process
  6. rescue ExternalDataSource::Errors::BaseError => e
  7. raise Exceptions::UnprocessableEntity, e.log_message(attribute_display)
  8. end
  9. def attribute_display
  10. "#{@attribute.object_lookup.name}.#{@attribute.name}"
  11. end
  12. end