class Eco::API::Common::Loaders::UseCase

Public Class Methods

new(usecases) click to toggle source
# 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
type(value = nil) click to toggle source

@return [Symbol] the `type` of usecase (i.e. `:sync`, `:transform`, `:import`, `:other`)

# 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

Public Instance Methods

main(entries, people, session, options, usecase) click to toggle source

The parameters of this method will depend on the `type` of usecase. @param entries [Eco::API::Common::People::Entries] the input entries with the data. @param people [Eco::API::Organization::People] the people in the queue of the current `job` @param session [Eco::API::Session] the current session where the usecase kicks in. @param options [Hash] the options that modify the case behaviour or bring some dependencies. @param usecase [Eco::API::Policies::Policy] the `usecase` instance object.

# 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
type() click to toggle source
# File lib/eco/api/common/loaders/use_case.rb, line 34
def type
  self.class.type
end