Sha256: cdf400866cea0c90ec01f2175fa8441ea3f7d52f21a17169eade6a73dd5ed56b

Contents?: true

Size: 1.6 KB

Versions: 72

Compression:

Stored size: 1.6 KB

Contents

module Eco
  module API
    module Common
      module Loaders
        class UseCase < Eco::API::Common::Loaders::CaseBase

          class << self
            # @return [Symbol] the `type` of usecase (i.e. `:sync`, `:transform`, `:import`, `:other`)
            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
          end

          inheritable_class_vars :type

          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

          # 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.
          def main(entries, people, session, options, usecase)
            raise "You should implement this method"
          end

          def type
            self.class.type
          end

        end
      end
    end
  end
end

Version data entries

72 entries across 72 versions & 1 rubygems

Version Path
eco-helpers-2.5.2 lib/eco/api/common/loaders/use_case.rb
eco-helpers-2.5.1 lib/eco/api/common/loaders/use_case.rb
eco-helpers-2.4.9 lib/eco/api/common/loaders/use_case.rb
eco-helpers-2.4.8 lib/eco/api/common/loaders/use_case.rb
eco-helpers-2.4.7 lib/eco/api/common/loaders/use_case.rb
eco-helpers-2.4.6 lib/eco/api/common/loaders/use_case.rb
eco-helpers-2.4.5 lib/eco/api/common/loaders/use_case.rb
eco-helpers-2.4.4 lib/eco/api/common/loaders/use_case.rb
eco-helpers-2.4.3 lib/eco/api/common/loaders/use_case.rb
eco-helpers-2.4.2 lib/eco/api/common/loaders/use_case.rb
eco-helpers-2.3.3 lib/eco/api/common/loaders/use_case.rb
eco-helpers-2.3.2 lib/eco/api/common/loaders/use_case.rb
eco-helpers-2.2.5 lib/eco/api/common/loaders/use_case.rb
eco-helpers-2.2.4 lib/eco/api/common/loaders/use_case.rb
eco-helpers-2.2.3 lib/eco/api/common/loaders/use_case.rb
eco-helpers-2.2.2 lib/eco/api/common/loaders/use_case.rb
eco-helpers-2.2.1 lib/eco/api/common/loaders/use_case.rb
eco-helpers-2.1.12 lib/eco/api/common/loaders/use_case.rb
eco-helpers-2.1.11 lib/eco/api/common/loaders/use_case.rb
eco-helpers-2.1.10 lib/eco/api/common/loaders/use_case.rb