Class: Hyrax::ModelDecorator

Inherits:
Draper::Decorator
  • Object
show all
Defined in:
lib/hyrax/model_decorator.rb

Overview

Provides ActiveModel-safe decoration via `Draper`.

This is needed to preserve Presenter, View, and URL helper behavior for decorated models.

Examples:

class TitleDecorator < Hyrax::ModelDecorator
  ##
  # @return [String]
  def title
    Array(object.title).first.capitalize
  end
end

my_model.title # => ['moomin']
decorated = TitleDecorator.decorate(my_model)

decorated.title # => 'Moomin'
url_helpers.download_url(decorated) == url_helpers.download_url(my_model) # => true

Direct Known Subclasses

SolrDocument::OrderedMembers

Instance Method Summary collapse

Instance Method Details

#to_model(*args) ⇒ Object


27
28
29
# File 'lib/hyrax/model_decorator.rb', line 27

def to_model(*args)
  object.to_model(*args)
end