forked from rubygarage/boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 1
Macro::Assign
Vladislav Trotsenko edited this page Oct 21, 2020
·
1 revision
Provides to assign into context value from other context/context chains.
class SomeOperation < ApplicationOperation
# ctx[:some_attribute] = ctx['contract.default'].some_attribute
step Macro::Assign(to: :some_attribute, path: %w[contract.default some_attribute])
# ctx[:model] = ctx[:current_account].user
step Macro::Assign(to: :model, path: %i[current_account user])
endclass SomeOperation < ApplicationOperation
step Macro::Assign(
to: :model,
path: %i[current_account not_existing_method],
try: true
) # ctx[:model] => nil
endclass SomeOperation < ApplicationOperation
# ctx[:some_attribute] = :some_value
step Macro::Assign(to: :some_attribute, value: :some_value)
end