usecasing icon indicating copy to clipboard operation
usecasing copied to clipboard

changes

Open junhanamaki opened this issue 11 years ago • 4 comments

  • 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

junhanamaki avatar Oct 02 '14 15:10 junhanamaki

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 avatar Oct 02 '14 15:10 junhanamaki

@junhanamaki It would be nice if you split this pull request in 4. One for each feature.

joaquimadraz avatar Oct 17 '14 10:10 joaquimadraz

@junhanamaki
"@joaquimadraz It would be nice if you split this pull request in 4. One for each feature. "

tdantas avatar May 27 '15 18:05 tdantas

@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?

junhanamaki avatar May 27 '15 21:05 junhanamaki