Sha256: 6df728b9141191f6f08344c4931e485860dc1668d25ede98e1d309ba6e543909
Contents?: true
Size: 1.31 KB
Versions: 139
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
139 entries across 139 versions & 1 rubygems