Sha256: 5ee9c5141e6b42f7b92065786f2c74be53b00dc4e60cfd50dbde7617dbcca144

Contents?: true

Size: 1001 Bytes

Versions: 106

Compression:

Stored size: 1001 Bytes

Contents

module Eco
  module API
    class MicroCases
      # Helper to preserve the original filter tags.
      # @note
      #   1. It only works if the original value of `filter_tags` was **not** empty
      # @param person [Ecoportal::API::V1::Person] the person we want to update, carrying the changes to be done.
      # @param options [Hash] the options.
      # @param keep_new [Boolean] tells if it should keep the new tags or get rid of them.
      # @return [Array<String>] the final value of `filter_tags`.
      def preserve_filter_tags(person, options, keep_new: false)
        if person.as_update.key?("filter_tags")
          if original  = person.original_doc["filter_tags"]
            unless original.empty?
              if keep_new
                person.filter_tags += original
              else
                person.filter_tags  = original
              end
            end
          end
        end
        person.filter_tags
      end

    end
  end
end

Version data entries

106 entries across 106 versions & 1 rubygems

Version Path
eco-helpers-2.7.20 lib/eco/api/microcases/preserve_filter_tags.rb
eco-helpers-2.7.19 lib/eco/api/microcases/preserve_filter_tags.rb
eco-helpers-2.7.18 lib/eco/api/microcases/preserve_filter_tags.rb
eco-helpers-2.7.17 lib/eco/api/microcases/preserve_filter_tags.rb
eco-helpers-2.7.16 lib/eco/api/microcases/preserve_filter_tags.rb
eco-helpers-2.7.15 lib/eco/api/microcases/preserve_filter_tags.rb
eco-helpers-2.7.14 lib/eco/api/microcases/preserve_filter_tags.rb
eco-helpers-2.7.13 lib/eco/api/microcases/preserve_filter_tags.rb
eco-helpers-2.7.12 lib/eco/api/microcases/preserve_filter_tags.rb
eco-helpers-2.7.4 lib/eco/api/microcases/preserve_filter_tags.rb
eco-helpers-2.7.2 lib/eco/api/microcases/preserve_filter_tags.rb
eco-helpers-2.7.1 lib/eco/api/microcases/preserve_filter_tags.rb
eco-helpers-2.7.0 lib/eco/api/microcases/preserve_filter_tags.rb
eco-helpers-2.6.4 lib/eco/api/microcases/preserve_filter_tags.rb
eco-helpers-2.6.3 lib/eco/api/microcases/preserve_filter_tags.rb
eco-helpers-2.6.2 lib/eco/api/microcases/preserve_filter_tags.rb
eco-helpers-2.6.1 lib/eco/api/microcases/preserve_filter_tags.rb
eco-helpers-2.6.0 lib/eco/api/microcases/preserve_filter_tags.rb
eco-helpers-2.5.10 lib/eco/api/microcases/preserve_filter_tags.rb
eco-helpers-2.5.9 lib/eco/api/microcases/preserve_filter_tags.rb