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.7.24 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-2.7.23 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-2.7.22 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-2.7.21 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-2.7.20 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-2.7.19 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-2.7.18 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-2.7.17 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-2.7.16 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-2.7.15 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-2.7.14 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-2.7.13 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-2.7.12 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-2.7.4 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-2.7.2 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-2.7.1 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-2.7.0 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-2.6.4 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-2.6.3 lib/eco/api/microcases/refresh_default_tag.rb
eco-helpers-2.6.2 lib/eco/api/microcases/refresh_default_tag.rb