Class: Novel::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/novel/base.rb

Constant Summary collapse

REPOSITORIES =
{
  memory: SagaRepository.new(adapter: RepositoryAdapters::Memory.new)
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(logger:, repository:, timeout:, **args) ⇒ Base

Returns a new instance of Base.



11
12
13
14
15
16
# File 'lib/novel/base.rb', line 11

def initialize(logger:, repository:, timeout:, **args)
  @logger = logger
  @repository = repository.is_a?(Symbol) ? REPOSITORIES[repository] : repository
  raise InvalidRepositoryError.new("Repository '#{repository}' does not exist in Novel. Please, use custom object insted") unless @repository
  @timeout = timeout
end

Instance Attribute Details

#loggerObject (readonly)

Returns the value of attribute logger.



3
4
5
# File 'lib/novel/base.rb', line 3

def logger
  @logger
end

#repositoryObject (readonly)

Returns the value of attribute repository.



3
4
5
# File 'lib/novel/base.rb', line 3

def repository
  @repository
end

Instance Method Details

#build(name:) ⇒ Object



18
19
20
# File 'lib/novel/base.rb', line 18

def build(name:)
  WorkflowBuilder.new(name: name, repository: repository)
end