Exception: Eco::API::Organization::People::MultipleSearchResults
- Inherits:
-
StandardError
- Object
- StandardError
- Eco::API::Organization::People::MultipleSearchResults
- Defined in:
- lib/eco/api/organization/people.rb
Overview
Note:
its main purpose to prevent the creation of duplicates or override information between different people.
Error class that allows to handle cases where multiple people were found for the same criterion.
Instance Attribute Summary collapse
-
#candidates ⇒ Object
readonly
Returns the value of attribute candidates.
-
#property ⇒ Object
readonly
Returns the value of attribute property.
Instance Method Summary collapse
-
#candidate(index) ⇒ Person
The
candidate
in theindex
position. -
#identify_candidates(with_index: false) ⇒ Array<String>
The
candidates
identified. -
#initialize(msg, candidates: [], property: "email") ⇒ MultipleSearchResults
constructor
A new instance of MultipleSearchResults.
Constructor Details
#initialize(msg, candidates: [], property: "email") ⇒ MultipleSearchResults
Returns a new instance of MultipleSearchResults.
12 13 14 15 16 |
# File 'lib/eco/api/organization/people.rb', line 12 def initialize(msg, candidates: [], property: "email") @candidates = candidates @property = property super(msg + " " + candidates_summary) end |
Instance Attribute Details
#candidates ⇒ Object (readonly)
Returns the value of attribute candidates.
8 9 10 |
# File 'lib/eco/api/organization/people.rb', line 8 def candidates @candidates end |
#property ⇒ Object (readonly)
Returns the value of attribute property.
8 9 10 |
# File 'lib/eco/api/organization/people.rb', line 8 def property @property end |
Instance Method Details
#candidate(index) ⇒ Person
Returns the candidate
in the index
position.
29 30 31 |
# File 'lib/eco/api/organization/people.rb', line 29 def candidate(index) candidates[index] end |
#identify_candidates(with_index: false) ⇒ Array<String>
Returns the candidates
identified.
20 21 22 23 24 25 26 |
# File 'lib/eco/api/organization/people.rb', line 20 def identify_candidates(with_index: false) candidates.map.each_with_index do |person, i| index = with_index ? "#{i}. " : "" msg = person.account ? (person.account_added? ? "(new user)" : "(user)") : "(no account)" "#{index}#{msg} #{person.identify}" end end |