forked from rubygarage/boilerplate
-
Notifications
You must be signed in to change notification settings - Fork 1
Macro::Model
Vladislav Trotsenko edited this page Oct 21, 2020
·
1 revision
Provides to assign model into context. Supports assign by relation chain, relation find_by
.
class SomeOperation < ApplicationOperation
step ->(ctx, **) { ctx[:some_model] = SomeModel.create }
step Macro::Model(
entity: :some_model, connections: %i[sub_object items], find_by_key: :id, params_key: :value
) # ctx[:model] = ctx[:some_model].sub_object.items.find_by(id: :value)
end
class SomeOperation < ApplicationOperation
step ->(ctx, **) { ctx[:some_model] = SomeModel.create }
step Macro::Model(
entity: :some_model, connections: %i[sub_object items], assign: true
) # ctx[:model] = ctx[:some_model].sub_object.items
end