Sha256: dc030d575eb56bc085c83e03d93d3760621ff7d6ef72d414a3189147eeddf21e

Contents?: true

Size: 1.13 KB

Versions: 139

Compression:

Stored size: 1.13 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)
        if person.account
          unless options.dig(:exclude, :account)
            unless options.dig(:exclude, :filter_tags) || options.dig(:exclude, :default_tag) || 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

    end
  end
end

Version data entries

139 entries across 139 versions & 1 rubygems

Version Path
eco-helpers-2.0.67 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-2.0.66 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-2.0.65 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-2.0.64 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-2.0.63 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-2.0.62 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-2.0.61 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-2.0.60 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-2.0.59 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-2.0.58 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-2.0.57 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-2.0.56 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-2.0.55 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-2.0.54 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-2.0.53 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-2.0.52 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-2.0.51 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-2.0.50 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-2.0.49 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-2.0.48 lib/eco/api/microcases/refresh_default_tag.rb