Class: Orcid::ProfileConnection

Inherits:
Object
  • Object
show all
Extended by:
ActiveModel::Naming
Includes:
ActiveModel::Conversion, ActiveModel::Validations
Defined in:
app/models/orcid/profile_connection.rb

Overview

Responsible for connecting an authenticated user to the ORCID profile that the user searched for and selected.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#orcid_profile_candidatesObject



55
56
57
# File 'app/models/orcid/profile_connection.rb', line 55

def orcid_profile_candidates
  @orcid_profile_candidates || lookup_profile_candidates
end

#profile_query_service=(value) ⇒ Object

Sets the attribute profile_query_service

Parameters:

  • value

    the value to set the attribute profile_query_service to.



35
36
37
# File 'app/models/orcid/profile_connection.rb', line 35

def profile_query_service=(value)
  @profile_query_service = value
end

Instance Method Details

#persisted?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'app/models/orcid/profile_connection.rb', line 31

def persisted?
  false
end

#query_attributesObject



71
72
73
74
75
76
77
# File 'app/models/orcid/profile_connection.rb', line 71

def query_attributes
  available_query_attribute_names.each_with_object({}) do |name, mem|
    orcid_formatted_name = convert_attribute_name_to_orcid_format(name)
    mem[orcid_formatted_name] = attributes.fetch(name)
    mem
  end
end

#save(collaborators = {}) ⇒ Object



24
25
26
27
28
29
# File 'app/models/orcid/profile_connection.rb', line 24

def save(collaborators = {})
  persister = collaborators.fetch(:persister) do
    Orcid.method(:connect_user_and_orcid_profile)
  end
  valid? ? persister.call(user, orcid_profile_id) : false
end

#with_orcid_profile_candidates {|orcid_profile_candidates| ... } ⇒ Object



49
50
51
# File 'app/models/orcid/profile_connection.rb', line 49

def with_orcid_profile_candidates
  yield(orcid_profile_candidates) if query_requested?
end