Sha256: 71b95ff067935893c274f4870173003cfe7ad2b0c0904b6c7a85db0ab3f3ded4
Contents?: true
Size: 995 Bytes
Versions: 258
Compression:
Stored size: 995 Bytes
Contents
module ForestLiana module DecorationHelper def self.detect_match_and_decorate record, index, field_name, value, search_value, match_fields begin match = value.match(/#{search_value}/i) if match match_fields[index] = { id: record['id'], search: [] } if match_fields[index].nil? match_fields[index][:search] << field_name end rescue end end def self.decorate_for_search(records_serialized, field_names, search_value) match_fields = {} records_serialized['data'].each_with_index do |record, index| field_names.each do |field_name| value = record['attributes'][field_name] if value detect_match_and_decorate(record, index, field_name, value, search_value, match_fields) end end detect_match_and_decorate(record, index, 'id', record['id'], search_value, match_fields) end match_fields.empty? ? nil : match_fields end end end
Version data entries
258 entries across 258 versions & 1 rubygems