Module: Eco::API::MicroCases::People::Fetch::WithEachSubordinate

Included in:
Eco::API::MicroCases::People::Fetch
Defined in:
lib/eco/api/microcases/people/fetch/with_each_subordinate.rb

Instance Method Summary collapse

Instance Method Details

#with_each_subordinate(supervisor, people) {|subordinate| ... } ⇒ Eco::API::Organization::People

Note:

if supervisor is nil, it will return all people with no supervisor.

Finds all the subordinates of supervisor.

Parameters:

  • supervisor (String, Ecoportal::API::V1::Person, Hash)

    the supervisor or the id / external_id thereof.

  • people (Eco::API::Organization::People)

    target existing People of the current update.

Yields:

  • (subordinate)

    block that does some stuff with subordinate.

Yield Parameters:

  • subordinate (Ecoportal::API::V1::Person)

    each one of the suborinates of supervisor.

Returns:



14
15
16
17
18
19
20
21
22
# File 'lib/eco/api/microcases/people/fetch/with_each_subordinate.rb', line 14

def with_each_subordinate(supervisor, people)
  people.supervisor_id(
    _person_id(supervisor, people)
  ).tap do |subordinates|
    subordinates.each do |subordinate|
      yield(subordinate) if block_given?
    end
  end
end