Class: Orcid::Profile
- Inherits:
-
Object
- Object
- Orcid::Profile
- Defined in:
- app/models/orcid/profile.rb
Overview
Provides a container around an Orcid Profile and its relation to the Orcid Works.
Instance Attribute Summary collapse
-
#orcid_profile_id ⇒ Object
readonly
Returns the value of attribute orcid_profile_id.
Instance Method Summary collapse
- #append_new_work(*works) ⇒ Object
-
#initialize(orcid_profile_id, collaborators = {}) ⇒ Profile
constructor
A new instance of Profile.
- #remote_works(options = {}) ⇒ Object
- #replace_works_with(*works) ⇒ Object
-
#verified_authentication? ⇒ Boolean
Answers the question: Has the user been authenticated via the ORCID system.
Constructor Details
#initialize(orcid_profile_id, collaborators = {}) ⇒ Profile
Returns a new instance of Profile.
7 8 9 10 11 12 13 |
# File 'app/models/orcid/profile.rb', line 7 def initialize(orcid_profile_id, collaborators = {}) @orcid_profile_id = orcid_profile_id @mapper = collaborators.fetch(:mapper) { default_mapper } @remote_service = collaborators.fetch(:remote_service) { default_remote_service } @xml_renderer = collaborators.fetch(:xml_renderer) { default_xml_renderer } @xml_parser = collaborators.fetch(:xml_parser) { default_xml_parser } end |
Instance Attribute Details
#orcid_profile_id ⇒ Object (readonly)
Returns the value of attribute orcid_profile_id.
5 6 7 |
# File 'app/models/orcid/profile.rb', line 5 def orcid_profile_id @orcid_profile_id end |
Instance Method Details
#append_new_work(*works) ⇒ Object
32 33 34 35 36 |
# File 'app/models/orcid/profile.rb', line 32 def append_new_work(*works) orcid_works = normalize_work(*works) xml = xml_renderer.call(orcid_works) remote_service.call(orcid_profile_id, request_method: :post, body: xml) end |
#remote_works(options = {}) ⇒ Object
24 25 26 27 28 29 30 |
# File 'app/models/orcid/profile.rb', line 24 def remote_works( = {}) @remote_works = nil if .fetch(:force, false) @remote_works ||= begin response = remote_service.call(orcid_profile_id, request_method: :get) xml_parser.call(response) end end |
#replace_works_with(*works) ⇒ Object
38 39 40 41 42 |
# File 'app/models/orcid/profile.rb', line 38 def replace_works_with(*works) orcid_works = normalize_work(*works) xml = xml_renderer.call(orcid_works) remote_service.call(orcid_profile_id, request_method: :put, body: xml) end |
#verified_authentication? ⇒ Boolean
Answers the question: Has the user been authenticated via the ORCID system.
is referenced via a controller, this can easily be moved.
20 21 22 |
# File 'app/models/orcid/profile.rb', line 20 def verified_authentication? Orcid.authenticated_orcid?(orcid_profile_id) end |