lib/liquid/drops/concepts_drop.rb in metanorma-plugin-glossarist-0.1.3 vs lib/liquid/drops/concepts_drop.rb in metanorma-plugin-glossarist-0.1.4
- old
+ new
@@ -2,11 +2,11 @@
module Liquid
module Drops
class ConceptsDrop < Liquid::Drop
# rubocop:disable Lint/MissingSuper
- NON_LANGUAGE_FIELDS = %w[term termid].freeze
+ NON_LANGUAGE_FIELDS = %w[term termid groups].freeze
def initialize(managed_concept_collection, filters = {})
@concepts_collection = managed_concept_collection
@concepts_map = {}
@@ -46,11 +46,17 @@
next
end
concept_filters.each do |name, value|
fields = extract_nested_field_names(name)
+ if fields.last.start_with?("start_with")
+ value = fields.last.gsub(/start_with\(([^\)]*)\)/, '\1')
+ fields = fields[0..-2]
- if filtered_concept.dig(*fields) != value
+ unless filtered_concept.dig(*fields).start_with?(value)
+ filtered_concept.delete(field)
+ end
+ elsif filtered_concept.dig(*fields) != value
filtered_concept.delete(field)
end
end
end