changes
-
we now can select the execution order that we prefer from:
- dependencies -> before -> perform (default, value false)
- before -> dependencies -> perform (value true)
just do:
UseCase.configure do |config|
# indicates which execution order we want
# value false (default) selects dependencies -> before -> perform
# value true select before -> dependencies -> perform
config.before_depends = false
end
- it's now possible to set accessors to attributes in context, for example instead of doing context.parameter we can just write parameter, this can be done with class methods:
class Case < UseCase::Base
context_reader :books
context_writer :review
context_accessor :comments
def perform
puts books # same as puts context.bookd
self.review = 'Very good' # same as context.review = 'Very good'
# self.comments and comments are also made available
end
end
- you can skip the execution flow by invoking skip!, this will interrupt the current UseCase and it's dependencies like stop!, but it will continue with the following UseCases:
def perform
skip! if context.to_skip
end
- it’s possible to insert a usecase to chain using invoke!:
def perform
invoke! AnotherUseCase
end
Opening pull request for discussion. Tests broken most likely because of how I persist nodes, will try to fix after knowing if the changes are good :)
PS: tests are fixed :)
@junhanamaki It would be nice if you split this pull request in 4. One for each feature.
@junhanamaki
"@joaquimadraz It would be nice if you split this pull request in 4. One for each feature. "
@tdantas
Do you see as a good compromise to just remove the features not suited for the project, as opposed to creating more pull requests?