-
Notifications
You must be signed in to change notification settings - Fork 9
Macro::Decorate
Vladislav Trotsenko edited this page Apr 10, 2020
·
1 revision
Provides to decorate everything from operation context with specified decorator (Draper::Decorator). Supports object or collection as an object for decoration.
class SomeOperation < ApplicationOperation
step :set_decorator # ctx[:decorator] = SomeDecorator
step :set_model # ctx[:model] = SomeEntity.new
step Macro::Decorate() # ctx[:model] = SomeDecorator.decorate(ctx[:model])
endclass SomeOperation < ApplicationOperation
step :set_model # ctx[:model] = SomeEntity.new
step Macro::Decorate(decorator: SomeDecorator) # ctx[:model] = SomeDecorator.decorate(ctx[:model])
endBy default :from and :to are ctx[:model]
class SomeOperation < ApplicationOperation
step :set_collection # ctx[:collection] = Array.new
step Macro::Decorate(decorator: SomeDecorator, from: :collection, to: :other_collection) # ctx[:other_collection] = SomeDecorator.decorate_collection(ctx[:collection])
endRubyGarage is a leading software development and consulting company in Eastern Europe. Our main expertise includes Ruby and Ruby on Rails, but we successfully employ other technologies to deliver the best results to our clients. Check out our portfolio for even more exciting works!
