Sha256: 05084ee0d40e9540f041dffffce012d4652718e56ef7f4b641dff5adeb27c850
Contents?: true
Size: 1.31 KB
Versions: 23
Compression:
Stored size: 1.31 KB
Contents
module Eco module API class MicroCases # Finds all the subordinates of `supervisor`. # @note if `supervisor` is `nil`, it will return all people with no supervisor. # @param supervisor [String, Ecoportal::API::V1::Person, Hash] the `supervisor` or the `id` / `external_id` thereof. # @param people [Eco::API::Organization::People] target existing _People_ of the current update. # @yield [subordinate] block that does some stuff with `subordinate`. # @yieldparam subordinate [Ecoportal::API::V1::Person] each one of the suborinates of `supervisor`. # @return [Eco::API::Organization::People] the **subordinates** of `supervisor`. 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 private def _person_id(value, people) case value when Hash _person_id(value["id"] || value["external_id"], people) when Ecoportal::API::V1::Person _person_id(value.id || value.external_id, people) when String micro.with_supervisor(value, people)&.id end end end end end
Version data entries
23 entries across 23 versions & 1 rubygems