Skip to main content

Business Logic

We user interactors heavily to encapsulate all our business logic.

Interactors#

Interactors should encapsulate the smallest, reusable section of business logic that is feasible. Interactors should be able to be used for more than a single use-case and should be able to be chained together.

Interactor validations should generally be at the top of the interactor in a before block. Context delegations should be declared at the top of the interactor class.

# Executes logic... some docs# @param merchant [Merchant]# @return value [Integer] something descriptiveclass Execute  include Interactor
  delegate :merchant, to: context
  before do    context.fail! if merchant.blank?  end
  def call    context.value = 100    ...  endend

Examples#

In our codebase: