Module: Eco::API::MicroCases::People::Fetch::WithSupervisor

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

Instance Method Summary collapse

Instance Method Details

#with_supervisor(value, people, strict: false) {|supervisor| ... } ⇒ nil, Ecoportal::API::V1::Person

Finds the supervisor among people by using the supervisor_id of value.

Parameters:

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

    the subordinate person, or the unique identifier of the supervisor to be found (preferably the external_id).

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

    target existing People of the current update.

  • strict (Boolean) (defaults to: false)

    specifies if the search should be strict (see Organization::People#person).

Yields:

  • (supervisor)

    block that does some stuff with supevisor.

Yield Parameters:

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

    the person object of the supervisor, or nil if not found.

Returns:

  • (nil, Ecoportal::API::V1::Person)

    found supervisor of value.



15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/eco/api/microcases/people/fetch/with_supervisor.rb', line 15

def with_supervisor(value, people, strict: false)
  if (sup_id = with_supervisor_supervisor_id(value))
    people.person(
      id:          sup_id,
      external_id: sup_id,
      email:       sup_id,
      strict:      strict
    )
  end.tap do |supervisor|
    yield(supervisor) if block_given?
  end
end