Class: Eco::API::Common::Loaders::UseCase
- Defined in:
- lib/eco/api/common/loaders/use_case.rb
Direct Known Subclasses
Eco::API::Custom::UseCase, UseCases::Default::Locations::CodesToTagsCase, UseCases::Default::Locations::CsvToTree, UseCases::Default::Locations::TagTreePaths, UseCases::Default::Meta::GraphQLSchema, UseCases::Default::People::Amend::CleanUnknownTags, UseCases::Default::People::Amend::ClearAbilitiesTransCase, UseCases::Default::People::Amend::RefreshCase, UseCases::Default::People::Amend::ReinviteTransCase, UseCases::Default::People::Amend::RestoreDBCase, UseCases::Default::People::Migrate::RemapTags, UseCases::Default::People::Treat::Analyse, UseCases::Default::People::Treat::OrgDataConvertCase, UseCases::Default::People::Treat::SupersCyclicIdentify, UseCases::Default::People::Treat::SupersHierarchy, UseCases::Default::People::Utils::ChangeEMailCase, UseCases::Default::People::Utils::SetDefaultTagCase, UseCases::Default::People::Utils::SwitchSupervisorCase, UseCases::Default::People::Utils::TransferAccountCase, UseCases::Default::Utils::JsonToCsv, UseCases::Default::Utils::SplitCsv, UseCases::Default::Utils::SplitJson, UseCases::DefaultCases::CreateCase, UseCases::DefaultCases::DeleteTransCase, UseCases::DefaultCases::EntriesToCsv, UseCases::DefaultCases::HrisCase, UseCases::DefaultCases::Samples::Sftp, UseCases::DefaultCases::ToCsvCase, UseCases::DefaultCases::UpdateCase, UseCases::DefaultCases::UpsertCase, UseCases::GraphQL::Base, UseCases::OozeSamples::OozeBaseCase, UseCases::OozeSamples::RegisterExportCase
Instance Attribute Summary
Attributes included from Language::AuxiliarLogger
Class Method Summary collapse
- .cli(cli_class = nil) ⇒ Object
- .cli! ⇒ Object
-
.type(value = nil) ⇒ Symbol
The
type
of usecase (i.e.:sync
,:transform
,:import
,:other
).
Instance Method Summary collapse
- #cli_apply! ⇒ Object
-
#initialize(usecases) ⇒ UseCase
constructor
rubocop:disable Lint/MissingSuper.
-
#main(entries, people, session, options, usecase) ⇒ Object
The parameters of this method will depend on the
type
of usecase. - #type ⇒ Object
Methods inherited from CaseBase
Methods inherited from Base
<=>, created_at, set_created_at!
Methods included from 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
Constructor Details
#initialize(usecases) ⇒ UseCase
rubocop:disable Lint/MissingSuper
45 46 47 48 49 50 |
# File 'lib/eco/api/common/loaders/use_case.rb', line 45 def initialize(usecases) # rubocop:disable Lint/MissingSuper msg = "Expected Eco::API::UseCases. Given #{usecases.class}" raise msg unless usecases.is_a?(Eco::API::UseCases) usecases.define(name, type: type, &method(:main)) end |
Class Method Details
.cli(cli_class = nil) ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/eco/api/common/loaders/use_case.rb', line 21 def cli(cli_class = nil) if cli_class.is_a?(Class) msg = "cli_class should inherit from Eco::API::UseCases::Cli" raise ArgumentError, msg unless cli_class < Eco::API::UseCases::Cli @cli = cli_class elsif cli_class.nil? return @cli if instance_variable_defined?(:@cli) && !@cli.nil? # try to see if it's namespaced after the use case it provisions cli integration begin try_class = [to_s, 'Cli'].join('::') @cli = Kernel.const_get(try_class) rescue NameError nil end else raise ArgumentError, "Expecting a class. Given: #{cli_class.class} object" end end |
.cli! ⇒ Object
17 18 19 |
# File 'lib/eco/api/common/loaders/use_case.rb', line 17 def cli! cli&.apply! end |
.type(value = nil) ⇒ Symbol
Returns the type
of usecase (i.e. :sync
, :transform
, :import
, :other
).
8 9 10 11 12 13 14 15 |
# File 'lib/eco/api/common/loaders/use_case.rb', line 8 def type(value = nil) unless value msg = "You should specify a type of case " msg << "[:sync, :transform, :import, :other] for #{self}" return @type || (raise msg) end @type = value end |
Instance Method Details
#cli_apply! ⇒ Object
66 67 68 |
# File 'lib/eco/api/common/loaders/use_case.rb', line 66 def cli_apply! self.class.cli! end |
#main(entries, people, session, options, usecase) ⇒ Object
The parameters of this method will depend on the type
of usecase.
58 59 60 |
# File 'lib/eco/api/common/loaders/use_case.rb', line 58 def main(entries, people, session, , usecase) # rubocop:disable Lint/UnusedMethodArgument raise "You should implement this method" end |
#type ⇒ Object
62 63 64 |
# File 'lib/eco/api/common/loaders/use_case.rb', line 62 def type self.class.type end |