Sha256: c036d552f0ffee21af8a1bdc5906c20668b31bfdfbf874380440ec77ec700bd8
Contents?: true
Size: 1.13 KB
Versions: 110
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) if account = person.account if account.as_update.key?("policy_group_ids") if original = person.original_doc.dig("account", "policy_group_ids") unless original.empty? if keep_new person.account.policy_group_ids += original else person.account.policy_group_ids = original end end end end end person.account&.policy_group_ids end end end end
Version data entries
110 entries across 110 versions & 1 rubygems