Sha256: 24a9c33a7346a5e1d2341470ec8b84891123f2ab54fdf451411d38c6b4eb92cb
Contents?: true
Size: 1.13 KB
Versions: 23
Compression:
Stored size: 1.13 KB
Contents
module Eco module API class MicroCases # Helper to preserve the original `policy_group_ids`. # @note # 1. It only works if the original value of `policy_group_ids` 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 policy groups or get rid of them. # @return [String] the final value of `policy_group_ids`. def preserve_policy_groups(person, _options, keep_new: false) return unless (account = person.account) account.policy_group_ids.tap do next unless account.as_update.key?("policy_group_ids") next unless (original = person.original_doc.dig("account", "policy_group_ids")) next if original.empty? if keep_new person.account.policy_group_ids += original else person.account.policy_group_ids = original end return account.policy_group_ids end end end end end
Version data entries
23 entries across 23 versions & 1 rubygems