I'm Mary Poppins, y'all!

auto_decorator

Zero-configuration, convention-based decorator autoloading for Rails models.

Ruby on RailsActive RecordDecorator

Convention-based decorator autoloading for Rails models.

Decorators are plain Ruby modules that get automatically included into your model classes based on file naming convention — no configuration required.

Why not Draper? Draper wraps objects in presenter classes. auto_decorator adds methods directly to the model. Less indirection, less boilerplate, same result for most use cases.

#Example

# app/decorators/user_decorator.rb
module UserDecorator
  def full_name
    [first_name, last_name].compact.join(" ")
  end
end
user = User.find(1)
user.full_name # => "Alice Smith"

Share this post