Class: Eco::API::Common::Loaders::UseCase

Inherits:
CaseBase show all
Extended by:
CliIdentify
Includes:
TargetModel, Type
Defined in:
lib/eco/api/common/loaders/use_case.rb,
lib/eco/api/common/loaders/use_case/type.rb,
lib/eco/api/common/loaders/use_case/cli_identify.rb,
lib/eco/api/common/loaders/use_case/target_model.rb

Defined Under Namespace

Modules: CliIdentify, TargetModel, Type

Instance Attribute Summary

Attributes included from Language::AuxiliarLogger

#logger

Instance Method Summary collapse

Methods included from CliIdentify

cli, cli!

Methods included from TargetModel

#target_model

Methods included from Type

#type

Methods inherited from CaseBase

#name, name_only_once!, original_name

Methods inherited from Base

<=>, created_at, set_created_at!

Methods included from Language::Klass::InheritableClassVars

#inheritable_attrs, #inheritable_class_vars, #inherited

Methods included from Language::Klass::Naming

#instance_variable_name, #to_constant

Methods included from Language::Klass::Hierarchy

#descendants, #descendants?

Methods included from Language::Klass::Builder

#new_class

Methods included from Language::Klass::Uid

#uid

Methods included from Language::Klass::Resolver

#class_resolver, #resolve_class

Methods included from Language::Klass::Const

#if_const, #redef_without_warning

Methods included from Language::AuxiliarLogger

#log

Constructor Details

#initialize(usecases) ⇒ UseCase

rubocop:disable Lint/MissingSuper



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/eco/api/common/loaders/use_case.rb', line 16

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,
    model: target_model,
    &method(:main)
  )
end

Instance Method Details

#cli_apply!Object



39
40
41
# File 'lib/eco/api/common/loaders/use_case.rb', line 39

def cli_apply!
  self.class.cli!
end

#main(*_args) ⇒ Object

The parameters of this method will depend on the type of usecase.

Parameters:

  • entries (Eco::API::Common::People::Entries)

    the input entries with the data.

  • data (Variant)
    • people [Eco::API::Organization::People] the people in the queue of the current job
  • session (Eco::API::Session)

    the current session where the usecase kicks in.

  • options (Hash)

    the options that modify the case behaviour or bring some dependencies.

  • usecase (Eco::API::Policies::Policy)

    the usecase instance object.



35
36
37
# File 'lib/eco/api/common/loaders/use_case.rb', line 35

def main(*_args)
  raise 'You should implement this method'
end