Skip to content
This repository was archived by the owner on Jun 5, 2024. It is now read-only.

Conversation

@junhanamaki
Copy link

  • 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

- method before is now called before UseCases set with depends, meaning
that the execution order is:

  - before -> dependencies -> perform

- 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 with class methods:

  - context_reader
  - context_writer
  - context_accessor

- 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

- it’s possible to insert a usecase to chain using invoke!
@junhanamaki
Copy link
Author

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 :)

@joaquimadraz
Copy link
Collaborator

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

@tdantas
Copy link
Owner

tdantas commented May 27, 2015

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

@junhanamaki
Copy link
Author

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants