Sha256: 41ff99918dca660493715fbb34f814d2259ff0adfc032666221d276128081bb9

Contents?: true

Size: 1.09 KB

Versions: 23

Compression:

Stored size: 1.09 KB

Contents

module Eco
  module API
    class MicroCases
      # When the input data, or `entry`, does not provide the `default_tag`,
      # it sets the `default_tag` of the user following some criteria
      # @note it assumes `default_tag` has been already set to `person.account`
      # @param entry [PersonEntry] the input entry with the data we should set on person.
      # @param person [Ecoportal::API::V1::Person] the person we want to update, carrying the changes to be done.
      # @param options [Hash] the options
      def refresh_default_tag(entry, person, options)
        return unless person.account
        return if options.dig(:exclude, :account)
        return if options.dig(:exclude, :filter_tags)
        return if options.dig(:exclude, :default_tag)
        return if entry&.default_tag?

        if session.tagtree
          person.account.default_tag = session.tagtree.default_tag(*person.filter_tags)
        else
          tags = person.filter_tags || []
          person.account.default_tag = tags.first unless tags.length > 1
        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/refresh_default_tag.rb
eco-helpers-3.0.20 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-3.0.19 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-3.0.18 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-3.0.17 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-3.0.16 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-3.0.15 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-3.0.14 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-3.0.13 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-3.0.12 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-3.0.11 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-3.0.10 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-3.0.9 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-3.0.8 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-3.0.7 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-3.0.6 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-3.0.5 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-3.0.4 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-3.0.3 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-3.0.2 lib/eco/api/microcases/refresh_default_tag.rb