Module: Eco::API::MicroCases::People::Fetch::WithEach
- Included in:
- Eco::API::MicroCases::People::Fetch
- Defined in:
- lib/eco/api/microcases/people/fetch/with_each.rb
Instance Method Summary collapse
-
#with_each(entries, people, options, append_created: true) {|entry, person| ... } ⇒ Eco::API::Organization::People
Finds each entry of
entriesinpeopleand runs a block.
Instance Method Details
#with_each(entries, people, options, append_created: true) {|entry, person| ... } ⇒ Eco::API::Organization::People
Note:
- it also links to
person.entrythe input data entry.
Finds each entry of entries in people and runs a block.
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/eco/api/microcases/people/fetch/with_each.rb', line 18 def with_each(entries, people, , append_created: true) @_skip_all_multiple_results = false people_copy = people.newFrom(people.to_a) entries.each_with_object([]) do |entry, scoped| begin person = people_copy.find(entry, strict: micro.strict_search?()) person ||= session.new_person.tap do |pers| people << pers if append_created end rescue Eco::API::Organization::People::MultipleSearchResults => e unless @_skip_all_multiple_results msg = "\n * When searching this Entry: #{entry.to_s(:identify)}" person = _with_each_prompt_to_select_user(e.(msg), entry: entry) end end next unless person person.entry = entry yield(entry, person) if block_given? scoped << person end.then do |all_people| people.newFrom all_people.uniq end end |