Class: Orcid::ProfileConnection
- Inherits:
-
Object
- Object
- Orcid::ProfileConnection
- 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
- #orcid_profile_candidates ⇒ Object readonly
-
#persister ⇒ Object
writeonly
Sets the attribute persister.
-
#profile_query_service ⇒ Object
writeonly
Sets the attribute profile_query_service.
Instance Method Summary collapse
- #default_persister ⇒ Object
- #persisted? ⇒ Boolean
- #query_attributes ⇒ Object
- #save ⇒ Object
- #with_orcid_profile_candidates {|orcid_profile_candidates| ... } ⇒ Object
Instance Attribute Details
#orcid_profile_candidates ⇒ Object
65 66 67 |
# File 'app/models/orcid/profile_connection.rb', line 65 def orcid_profile_candidates @orcid_profile_candidates || lookup_profile_candidates end |
#persister=(value) ⇒ Object
Sets the attribute persister
34 35 36 |
# File 'app/models/orcid/profile_connection.rb', line 34 def persister=(value) @persister = value end |
#profile_query_service=(value) ⇒ Object
Sets the attribute profile_query_service
45 46 47 |
# File 'app/models/orcid/profile_connection.rb', line 45 def profile_query_service=(value) @profile_query_service = value end |
Instance Method Details
#default_persister ⇒ Object
40 41 42 43 |
# File 'app/models/orcid/profile_connection.rb', line 40 def default_persister require 'orcid' Orcid.method(:connect_user_and_orcid_profile) end |
#persisted? ⇒ Boolean
30 31 32 |
# File 'app/models/orcid/profile_connection.rb', line 30 def persisted? false end |
#query_attributes ⇒ Object
81 82 83 84 85 86 87 |
# File 'app/models/orcid/profile_connection.rb', line 81 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 ⇒ Object
26 27 28 |
# File 'app/models/orcid/profile_connection.rb', line 26 def save valid? ? persister.call(user, orcid_profile_id) : false end |
#with_orcid_profile_candidates {|orcid_profile_candidates| ... } ⇒ Object
59 60 61 |
# File 'app/models/orcid/profile_connection.rb', line 59 def with_orcid_profile_candidates yield(orcid_profile_candidates) if query_requested? end |