* Add Profiles::Update service object * Refactor * Rename Profile.fields to Profile.attributes * Keep sync from user -> profile * And and update comments * Rename Profile.refresh_store_accessors! * Make forwarding getters in user dynamic * Add more explanation * Fix typo * Update service object * Fix return value * Fix specs * Travis, let's be friends again? * Remove Travis change * Add require_dependency in Profile * Refactor * More refactoring * Avoid double sync * Fix specs * Fix mapped attributes sync
14 lines
478 B
Ruby
14 lines
478 B
Ruby
module Profiles
|
|
module ExtractData
|
|
def self.call(user)
|
|
user_attributes = user.attributes
|
|
|
|
mapped_attributes = Profile::MAPPED_ATTRIBUTES.transform_values(&:to_s)
|
|
direct_attributes = Profile.attributes! - mapped_attributes.keys
|
|
direct_data = user_attributes.extract!(*direct_attributes)
|
|
mapped_data = mapped_attributes.keys.zip(user_attributes.values_at(*mapped_attributes.values)).to_h
|
|
|
|
direct_data.merge(mapped_data)
|
|
end
|
|
end
|
|
end
|