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.2.3 lib/eco/api/microcases/preserve_filter_tags.rb
eco-helpers-2.2.2 lib/eco/api/microcases/preserve_filter_tags.rb
eco-helpers-2.2.1 lib/eco/api/microcases/preserve_filter_tags.rb
eco-helpers-2.1.12 lib/eco/api/microcases/preserve_filter_tags.rb
eco-helpers-2.1.11 lib/eco/api/microcases/preserve_filter_tags.rb
eco-helpers-2.1.10 lib/eco/api/microcases/preserve_filter_tags.rb
eco-helpers-2.1.9 lib/eco/api/microcases/preserve_filter_tags.rb
eco-helpers-2.1.8 lib/eco/api/microcases/preserve_filter_tags.rb
eco-helpers-2.1.7 lib/eco/api/microcases/preserve_filter_tags.rb
eco-helpers-2.1.6 lib/eco/api/microcases/preserve_filter_tags.rb
eco-helpers-2.1.5 lib/eco/api/microcases/preserve_filter_tags.rb
eco-helpers-2.1.4 lib/eco/api/microcases/preserve_filter_tags.rb
eco-helpers-2.1.3 lib/eco/api/microcases/preserve_filter_tags.rb
eco-helpers-2.1.2 lib/eco/api/microcases/preserve_filter_tags.rb
eco-helpers-2.1.1 lib/eco/api/microcases/preserve_filter_tags.rb
eco-helpers-2.0.68 lib/eco/api/microcases/preserve_filter_tags.rb
eco-helpers-2.0.67 lib/eco/api/microcases/preserve_filter_tags.rb
eco-helpers-2.0.66 lib/eco/api/microcases/preserve_filter_tags.rb
eco-helpers-2.0.65 lib/eco/api/microcases/preserve_filter_tags.rb
eco-helpers-2.0.64 lib/eco/api/microcases/preserve_filter_tags.rb