Class: Orcid::ProfileStatus
- Inherits:
-
Object
- Object
- Orcid::ProfileStatus
- Defined in:
- app/models/orcid/profile_status.rb
Overview
ProfileStatus.status :authenticated_connection - User has authenticated against the Orcid
remote system
:pending_connection - User has indicated there is a connection, but has
not authenticated against the Orcid remote system
:profile_request_pending - User has requested a profile be created on
their behalf
:unknown - None of the above
Instance Attribute Summary collapse
-
#callback_handler ⇒ Object
readonly
Returns the value of attribute callback_handler.
-
#profile_finder ⇒ Object
readonly
Returns the value of attribute profile_finder.
-
#request_finder ⇒ Object
readonly
Returns the value of attribute request_finder.
-
#user ⇒ Object
readonly
Returns the value of attribute user.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(user, collaborators = {}) {|callback_handler| ... } ⇒ ProfileStatus
constructor
A new instance of ProfileStatus.
- #status ⇒ Object
Constructor Details
#initialize(user, collaborators = {}) {|callback_handler| ... } ⇒ ProfileStatus
Returns a new instance of ProfileStatus.
17 18 19 20 21 22 23 |
# File 'app/models/orcid/profile_status.rb', line 17 def initialize(user, collaborators = {}) @user = user @profile_finder = collaborators.fetch(:profile_finder) { default_profile_finder } @request_finder = collaborators.fetch(:request_finder) { default_request_finder } @callback_handler = collaborators.fetch(:callback_handler) { default_callback_handler } yield(callback_handler) if block_given? end |
Instance Attribute Details
#callback_handler ⇒ Object (readonly)
Returns the value of attribute callback_handler.
15 16 17 |
# File 'app/models/orcid/profile_status.rb', line 15 def callback_handler @callback_handler end |
#profile_finder ⇒ Object (readonly)
Returns the value of attribute profile_finder.
15 16 17 |
# File 'app/models/orcid/profile_status.rb', line 15 def profile_finder @profile_finder end |
#request_finder ⇒ Object (readonly)
Returns the value of attribute request_finder.
15 16 17 |
# File 'app/models/orcid/profile_status.rb', line 15 def request_finder @request_finder end |
#user ⇒ Object (readonly)
Returns the value of attribute user.
15 16 17 |
# File 'app/models/orcid/profile_status.rb', line 15 def user @user end |
Class Method Details
.for(user, collaborators = {}, &block) ⇒ Object
11 12 13 |
# File 'app/models/orcid/profile_status.rb', line 11 def self.for(user, collaborators = {}, &block) new(user, collaborators, &block).status end |
Instance Method Details
#status ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'app/models/orcid/profile_status.rb', line 25 def status return callback(:unknown) if user.nil? profile = profile_finder.call(user) if profile if profile.verified_authentication? return callback(:authenticated_connection, profile) else return callback(:pending_connection, profile) end else request = request_finder.call(user) if request return callback(:profile_request_pending, request) else return callback(:unknown) end end return callback(:unknown) end |