Migrated custom LDAP import_job.dry_run Unit to shared Unit based on new simple provider structure and delegation pattern.

This commit is contained in:
Thorsten Eckel 2018-01-08 16:28:30 +01:00
parent de6d8c54ae
commit 5a6f3f1a38
4 changed files with 44 additions and 21 deletions

View file

@ -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',

View file

@ -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

View file

@ -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

View file

@ -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