Class: Eco::API::Custom::Policy

Overview

Helper class to create a custom Policy

Examples:

Example of usage:

class Custom::Policy::StartersNLeavers < Eco::API::Custom::Policy
  name "starters'n'leavers"

  INACTIVE = "Non active"

  def main(people, session, options, policy, job)
    people.each do |person|
      next unless details = person.details
      # starters
      if person.new?
        details["status"]       = "Active"
        details["hris-managed"] = true unless options.dig(:include, :excluded)
      end

      # leavers: native job queue to remove account
      if job.name == "leavers"
        details["status"]    = INACTIVE
        person.external_id   = person.name
        details["staff-id"]  = person.name
      end
    end
  end

end

Instance Attribute Summary

Attributes included from Language::AuxiliarLogger

#logger

Method Summary

Methods inherited from Eco::API::Common::Loaders::Policy

#initialize, #main

Methods inherited from Eco::API::Common::Loaders::CaseBase

#name, name_only_once!

Methods inherited from Eco::API::Common::Loaders::Base

<=>, created_at, #initialize, set_created_at!

Methods included from Eco::API::Common::ClassHelpers

#class_resolver, #descendants, #descendants?, #inheritable_attrs, #inheritable_class_vars, #inherited, #instance_variable_name, #new_class, #resolve_class, #to_constant

Methods included from Language::AuxiliarLogger

#log

Constructor Details

This class inherits a constructor from Eco::API::Common::Loaders::Policy