Class: UserSyncedAttributesMetadata

Inherits:
ApplicationRecord show all
Defined in:
app/models/user_synced_attributes_metadata.rb

Constant Summary collapse

SYNCABLE_ATTRIBUTES =
%i[name email location].freeze

Instance Method Summary collapse

Methods inherited from ApplicationRecord

at_most, id_in, id_not_in, iid_in, pluck_primary_key, primary_key_in, safe_ensure_unique, safe_find_or_create_by, safe_find_or_create_by!, underscore, without_order

Instance Method Details

#read_only?(attribute) ⇒ Boolean

Returns:

  • (Boolean)

10
11
12
# File 'app/models/user_synced_attributes_metadata.rb', line 10

def read_only?(attribute)
  sync_profile_from_provider? && synced?(attribute)
end

#read_only_attributesObject


14
15
16
17
18
# File 'app/models/user_synced_attributes_metadata.rb', line 14

def read_only_attributes
  return [] unless sync_profile_from_provider?

  SYNCABLE_ATTRIBUTES.select { |key| synced?(key) }
end

#set_attribute_synced(attribute, value) ⇒ Object


24
25
26
# File 'app/models/user_synced_attributes_metadata.rb', line 24

def set_attribute_synced(attribute, value)
  write_attribute("#{attribute}_synced", value)
end

#synced?(attribute) ⇒ Boolean

Returns:

  • (Boolean)

20
21
22
# File 'app/models/user_synced_attributes_metadata.rb', line 20

def synced?(attribute)
  read_attribute("#{attribute}_synced")
end