Good overview of decorator options for ruby listed in thoughtbot article
The simplest implementation is:
class Decorator < SimpleDelegator
def self.wrap(collection)
collection.map do |obj|
new obj
end
end
# to mimic draper
# Be aware that draper does some magic to implement it,
# so this will not work exactly the same as draper
# https://github.com/drapergem/draper/blob/master/lib/draper/view_context.rb
def h
ActionController::Base.helpers
end
end
class WorkerDecorator < Decorator
end
See also this article.
Draper
Draper is de facto choice for Rails projects. But be aware that there are some issues with it:
Cells
Cells is part of trailblazer project, which tries to bring “a high-level architecture for web applications”.