forest_liana 2.11.4 → 2.11.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 27a991fcb1461f7ae2d75fc7466d594e6880dc07
4
- data.tar.gz: eb99b4bd4942157e688de0d6d96c4e0f4438b901
3
+ metadata.gz: 53c92d1f05cf2ff65b4e6d79d5b20d2b7ed10902
4
+ data.tar.gz: 0e609dc60a722db616fce19af67d9de605bb49f2
5
5
  SHA512:
6
- metadata.gz: 5aa50663e693770a1221952acd46bd18ad7499b3158cbc04fef560fc922095cd3ce473e263c814285c264437eef79c510dea3bd14ae2bb6f0fc49045286ddbc4
7
- data.tar.gz: a8651c285656b8ef6869afa08c13f55c81b990547a9fdf24ef26cc4a33ed1660ace9088e6459d1873c0cf3d228a36d5f146c190e4dd0d50a4b490f7a6184cd8f
6
+ metadata.gz: 36b9c24abe24331f6106e2500485c2f8ab6de2ade269f05369ecd976862e1335e5b87167e44f3f59d286231e5c583dd8a0cb6352f433a8173a02b72444789e30
7
+ data.tar.gz: 29b1568a5c7b6c7db4c24806fd84e5053219a95bf1532ba2647ea19480cca78da91ada9de6a47ea9d90320faf7dfd4dd4f8897b0d0e661c7b005c8c377968702
@@ -1,18 +1,27 @@
1
1
  module ForestLiana
2
2
  module DecorationHelper
3
+ def self.detect_match_and_decorate record, index, field_name, value, search_value, match_fields
4
+ begin
5
+ match = value.match(/#{search_value}/i)
6
+ if match
7
+ match_fields[index] = { id: record['id'], search: [] } if match_fields[index].nil?
8
+ match_fields[index][:search] << field_name
9
+ end
10
+ rescue
11
+ end
12
+ end
13
+
3
14
  def self.decorate_for_search(records_serialized, field_names, search_value)
4
15
  match_fields = {}
5
16
  records_serialized['data'].each_with_index do |record, index|
6
17
  field_names.each do |field_name|
7
18
  value = record['attributes'][field_name]
8
19
  if value
9
- match = value.match(/#{search_value}/i)
10
- if match
11
- match_fields[index] = { id: record['id'], search: [] } if match_fields[index].nil?
12
- match_fields[index][:search] << field_name
13
- end
20
+ detect_match_and_decorate(record, index, field_name, value, search_value, match_fields)
14
21
  end
15
22
  end
23
+
24
+ detect_match_and_decorate(record, index, 'id', record['id'], search_value, match_fields)
16
25
  end
17
26
  match_fields.empty? ? nil : match_fields
18
27
  end
@@ -1,3 +1,3 @@
1
1
  module ForestLiana
2
- VERSION = "2.11.4"
2
+ VERSION = "2.11.5"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forest_liana
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.11.4
4
+ version: 2.11.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sandro Munda