From 5a6f3f1a388eaf3013379e391e2bb89ae7fa26a9 Mon Sep 17 00:00:00 2001 From: Thorsten Eckel Date: Mon, 8 Jan 2018 16:28:30 +0100 Subject: [PATCH] Migrated custom LDAP import_job.dry_run Unit to shared Unit based on new simple provider structure and delegation pattern. --- lib/sequencer/sequence/import/ldap/users.rb | 2 +- lib/sequencer/unit/common/provider/named.rb | 27 +++++++++++++++++++ .../unit/import/common/import_job/dry_run.rb | 16 +++++++++++ .../unit/import/ldap/users/dry_run/flag.rb | 20 -------------- 4 files changed, 44 insertions(+), 21 deletions(-) create mode 100644 lib/sequencer/unit/common/provider/named.rb create mode 100644 lib/sequencer/unit/import/common/import_job/dry_run.rb delete mode 100644 lib/sequencer/unit/import/ldap/users/dry_run/flag.rb diff --git a/lib/sequencer/sequence/import/ldap/users.rb b/lib/sequencer/sequence/import/ldap/users.rb index 549a08f2e..8fe55e608 100644 --- a/lib/sequencer/sequence/import/ldap/users.rb +++ b/lib/sequencer/sequence/import/ldap/users.rb @@ -7,7 +7,7 @@ class Sequencer def self.sequence [ 'Import::Ldap::Users::StaticAttributes', - 'Import::Ldap::Users::DryRun::Flag', + 'Import::Common::ImportJob::DryRun', 'Import::Ldap::Users::DryRun::Payload', 'Ldap::Config', 'Ldap::Connection', diff --git a/lib/sequencer/unit/common/provider/named.rb b/lib/sequencer/unit/common/provider/named.rb new file mode 100644 index 000000000..b2c3e1a51 --- /dev/null +++ b/lib/sequencer/unit/common/provider/named.rb @@ -0,0 +1,27 @@ +class Sequencer + class Unit + module Common + module Provider + class Named < Sequencer::Unit::Common::Provider::Attribute + + module ClassMethods + def named_provide + name.demodulize.underscore.to_sym + end + end + + def self.inherited(base) + base.extend(ClassMethods) + base.provides(base.named_provide) + + base.extend(Forwardable) + end + + def provides + self.class.named_provide + end + end + end + end + end +end diff --git a/lib/sequencer/unit/import/common/import_job/dry_run.rb b/lib/sequencer/unit/import/common/import_job/dry_run.rb new file mode 100644 index 000000000..b95ccd759 --- /dev/null +++ b/lib/sequencer/unit/import/common/import_job/dry_run.rb @@ -0,0 +1,16 @@ +class Sequencer + class Unit + module Import + module Common + module ImportJob + class DryRun < Sequencer::Unit::Common::Provider::Named + + uses :import_job + + delegate dry_run: :import_job + end + end + end + end + end +end diff --git a/lib/sequencer/unit/import/ldap/users/dry_run/flag.rb b/lib/sequencer/unit/import/ldap/users/dry_run/flag.rb deleted file mode 100644 index 948a58c33..000000000 --- a/lib/sequencer/unit/import/ldap/users/dry_run/flag.rb +++ /dev/null @@ -1,20 +0,0 @@ -class Sequencer - class Unit - module Import - module Ldap - module Users - class DryRun - class Flag < Sequencer::Unit::Base - uses :import_job - provides :dry_run - - def process - state.provide(:dry_run, import_job.dry_run) - end - end - end - end - end - end - end -end