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

Inherits:
BaseLoader
  • Object
show all
Defined in:
lib/eco/api/common/loaders/use_case.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseLoader

<=>, created_at, #name, name_only_once!, set_created_at!

Methods included from ClassHelpers

#class_resolver, #descendants, #descendants?, #new_class, #resolve_class, #to_constant

Constructor Details

#initialize(usecases) ⇒ UseCase

Returns a new instance of UseCase.



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

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.class}")
  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:



28
29
30
# File 'lib/eco/api/common/loaders/use_case.rb', line 28

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

#typeObject



32
33
34
# File 'lib/eco/api/common/loaders/use_case.rb', line 32

def type
  self.class.type
end