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

Inherits:
CaseBase show all
Defined in:
lib/eco/api/common/loaders/use_case.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from CaseBase

#name, name_only_once!

Methods inherited from Base

<=>, created_at, #name, 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

Constructor Details

#initialize(usecases) ⇒ UseCase

Returns a new instance of UseCase.



19
20
21
22
# File 'lib/eco/api/common/loaders/use_case.rb', line 19

def initialize(usecases)
  raise "Expected Eco::API::UseCases. Given #{usecases.class}" unless usecases.is_a?(Eco::API::UseCases)
  usecases.define(self.name, type: self.type, &self.method(:main))
end

Class Method Details

.type(value = nil) ⇒ Symbol

Returns the type of usecase (i.e. :sync, :transform, :import, :other).

Returns:

  • (Symbol)

    the type of usecase (i.e. :sync, :transform, :import, :other)



9
10
11
12
13
14
# File 'lib/eco/api/common/loaders/use_case.rb', line 9

def type(value = nil)
  unless value
    return @type || raise("You should specify a type of case [:sync, :transform, :import, :other] for #{self}")
  end
  @type = value
end

Instance Method Details

#main(entries, people, session, options, usecase) ⇒ Object

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

Parameters:



30
31
32
# File 'lib/eco/api/common/loaders/use_case.rb', line 30

def main(entries, people, session, options, usecase)
  raise "You should implement this method"
end

#typeObject



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

def type
  self.class.type
end