Sha256: ade19c28e3dcc44129a0bc23efa2918b0aa87dc09efaf1d6a6016c0cb2a329b8

Contents?: true

Size: 831 Bytes

Versions: 23

Compression:

Stored size: 831 Bytes

Contents

module Eco
  module API
    class MicroCases
      # Helper to preserve the original `default_tag`.
      # @note
      #   1. It only works if the original value of `default_tag` 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.
      # @return [String] the final value of `default_tag`.
      def preserve_default_tag(person, _options)
        return unless (account = person.account)

        account.default_tag.tap do
          next unless account.as_update.key?("default_tag")
          next unless (original = person.original_doc.dig("account", "default_tag"))

          person.account.default_tag = original
          return original
        end
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
eco-helpers-3.0.21 lib/eco/api/microcases/preserve_default_tag.rb
eco-helpers-3.0.20 lib/eco/api/microcases/preserve_default_tag.rb
eco-helpers-3.0.19 lib/eco/api/microcases/preserve_default_tag.rb
eco-helpers-3.0.18 lib/eco/api/microcases/preserve_default_tag.rb
eco-helpers-3.0.17 lib/eco/api/microcases/preserve_default_tag.rb
eco-helpers-3.0.16 lib/eco/api/microcases/preserve_default_tag.rb
eco-helpers-3.0.15 lib/eco/api/microcases/preserve_default_tag.rb
eco-helpers-3.0.14 lib/eco/api/microcases/preserve_default_tag.rb
eco-helpers-3.0.13 lib/eco/api/microcases/preserve_default_tag.rb
eco-helpers-3.0.12 lib/eco/api/microcases/preserve_default_tag.rb
eco-helpers-3.0.11 lib/eco/api/microcases/preserve_default_tag.rb
eco-helpers-3.0.10 lib/eco/api/microcases/preserve_default_tag.rb
eco-helpers-3.0.9 lib/eco/api/microcases/preserve_default_tag.rb
eco-helpers-3.0.8 lib/eco/api/microcases/preserve_default_tag.rb
eco-helpers-3.0.7 lib/eco/api/microcases/preserve_default_tag.rb
eco-helpers-3.0.6 lib/eco/api/microcases/preserve_default_tag.rb
eco-helpers-3.0.5 lib/eco/api/microcases/preserve_default_tag.rb
eco-helpers-3.0.4 lib/eco/api/microcases/preserve_default_tag.rb
eco-helpers-3.0.3 lib/eco/api/microcases/preserve_default_tag.rb
eco-helpers-3.0.2 lib/eco/api/microcases/preserve_default_tag.rb