Class: Autoselect::TaxonName::Autoselect

Inherits:
Base
  • Object
show all
Defined in:
lib/autoselect/taxon_name/autoselect.rb

Constant Summary

Constants included from Operators

Operators::OPERATORS

Instance Attribute Summary

Attributes inherited from Base

#level_params, #project_id, #raw_term, #requested_level, #user_id

Instance Method Summary collapse

Methods inherited from Base

#build_config, #config_response, #execute_level, #find_level, #initialize, #level_map_keys, #next_level_key, #record_list_operator?, #response, #term_response

Methods included from Operators

included, #parse_operators

Constructor Details

This class inherits a constructor from Autoselect::Base

Instance Method Details

#format_results(records, level_instance) ⇒ Object (private)

Override to populate extension from CoL pseudo-records.



28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/autoselect/taxon_name/autoselect.rb', line 28

def format_results(records, level_instance)
  records.map do |record|
    {
      id: record.id,
      global_id: record.respond_to?(:to_global_id) ? record.to_global_id.to_s : nil,
      label: level_instance.record_label(record),
      label_html: level_instance.record_label_html(record),
      info_html: @show_info ? level_instance.record_info_html(record) : '',
      response_values: response_values(record),
      extension: record.respond_to?(:_col_extension) ? record._col_extension : {}
    }
  end
end

#levelsObject

Ordered level stack — defines the fuse escalation sequence.



11
12
13
14
15
16
17
# File 'lib/autoselect/taxon_name/autoselect.rb', line 11

def levels
  [
    ::Autoselect::TaxonName::Levels::Fast.new,
    ::Autoselect::TaxonName::Levels::Smart.new,
    ::Autoselect::TaxonName::Levels::CatalogueOfLife.new,
  ]
end

#resource_pathObject



6
7
8
# File 'lib/autoselect/taxon_name/autoselect.rb', line 6

def resource_path
  '/taxon_names/autoselect'
end

#response_values(record) ⇒ Hash

Returns key-value pairs injected into the parent form on selection.

Parameters:

Returns:

  • (Hash)

    key-value pairs injected into the parent form on selection



21
22
23
# File 'lib/autoselect/taxon_name/autoselect.rb', line 21

def response_values(record)
  { taxon_name_id: record.id }
end