Skip to content

Macro::ModelDestroy

Vladislav Trotsenko edited this page Sep 27, 2019 · 1 revision

Synopsis

Provides to destroy last model in chain.

Examples of usage

Without chain

class SomeOperation < ApplicationOperation
  step ->(ctx, **) { ctx[:some_model] = SomeModel.create }
  step Macro::ModelDestroy(path: %i[some_model]) # ctx[:some_model].destroy
end

With chain

class SomeOperation < ApplicationOperation
  step ->(ctx, **) { ctx[:some_model] = SomeModel.create }
  step Macro::ModelDestroy(path: %i[some_model some_relation]) # ctx[:some_model].some_relation.destroy
end
Clone this wiki locally