lib/eco/api/common/people/person_entry.rb in eco-helpers-2.0.26 vs lib/eco/api/common/people/person_entry.rb in eco-helpers-2.0.27
- old
+ new
@@ -186,11 +186,11 @@
# Meaning that if an core property is not present in the entry, this will not be set on the target person.
# 2. if there's an incorrect email exception, it blanks the email and logs a warning message
# @param person [Ecoportal::API::V1::Person] the person we want to set the core values to.
# @param exclude [String, Array<String>] core attributes that should not be set/changed to the person.
def set_core(person, exclude: nil)
- scoped_attrs = @emap.core_attrs - into_a(exclude)
+ scoped_attrs = @emap.core_attrs(@final_entry) - into_a(exclude)
@final_entry.slice(*scoped_attrs).each do |attr, value|
begin
set_part(person, attr, value)
rescue Exception => e
if attr == "email"
@@ -208,11 +208,11 @@
# Meaning that if an account property is not present in the entry, this will not be set on the target person.
# @param person [Ecoportal::API::Internal::Person] the person we want to set the account values to.
# @param exclude [String, Array<String>] account properties that should not be set/changed to the person.
def set_account(person, exclude: nil)
person.account = {} if !person.account
- scoped_attrs = @emap.account_attrs - into_a(exclude)
+ scoped_attrs = @emap.account_attrs(@final_entry) - into_a(exclude)
@final_entry.slice(*scoped_attrs).each do |attr, value|
set_part(person.account, attr, value)
end
end
@@ -222,11 +222,11 @@
# Meaning that if an details property is not present in the entry, this will not be set on the target person.
# @param person [Ecoportal::API::V1::Person] the person we want to set the schema fields' values to.
# @param exclude [String, Array<String>] schema field attributes that should not be set/changed to the person.
def set_details(person, exclude: nil)
person.add_details(@person_parser.schema) if !person.details || !person.details.schema_id
- scoped_attrs = @emap.details_attrs - into_a(exclude)
+ scoped_attrs = @emap.details_attrs(@final_entry) - into_a(exclude)
@final_entry.slice(*scoped_attrs).each do |attr, value|
set_part(person.details, attr, value)
end
end
@@ -324,15 +324,16 @@
# Parsing helper where attributes with custom parsers are already parsed, but
# it finishes to parse the types (i.e. to `Array` if `multiple`)
# @param internal_entry [Hash] the entry with the **internal** _attribute_ names and values but the **external** types.
# @return [Hash] the `parsed entry` with the **internal** final attributes names, values and types.
def _final_parsing(internal_entry)
- core_account = @emap.account_attrs + @emap.core_attrs
- core_account_hash = internal_entry.slice(*core_account).each_with_object({}) do |(attr, value), hash|
+ core_account_attrs = @emap.account_attrs(internal_entry) + @emap.core_attrs(internal_entry)
+ core_account_hash = internal_entry.slice(*core_account_attrs).each_with_object({}) do |(attr, value), hash|
hash[attr] = _parse_type(attr, value)
end
- details_hash = internal_entry.slice(*@emap.details_attrs).each_with_object({}) do |(attr, value), hash|
+ details_attrs = @emap.details_attrs(internal_entry)
+ details_hash = internal_entry.slice(*details_attrs).each_with_object({}) do |(attr, value), hash|
hash[attr] = _parse_type(attr, value, schema: @person_parser.schema)
end
merging(core_account_hash, details_hash) do |final_entry|
final_entry = merge_missing_attrs(final_entry, internal_entry)