Class: Hyrax::PresenterRenderer

Inherits:
Object
  • Object
show all
Includes:
ActionView::Helpers::TranslationHelper
Defined in:
app/presenters/hyrax/presenter_renderer.rb

Instance Method Summary collapse

Constructor Details

#initialize(presenter, view_context) ⇒ PresenterRenderer

Returns a new instance of PresenterRenderer.


5
6
7
8
# File 'app/presenters/hyrax/presenter_renderer.rb', line 5

def initialize(presenter, view_context)
  @presenter = presenter
  @view_context = view_context
end

Instance Method Details

#fields(terms, &_block) ⇒ Object


20
21
22
# File 'app/presenters/hyrax/presenter_renderer.rb', line 20

def fields(terms, &_block)
  @view_context.safe_join(terms.map { |term| yield self, term })
end

#label(field) ⇒ Object


14
15
16
17
18
# File 'app/presenters/hyrax/presenter_renderer.rb', line 14

def label(field)
  t(:"#{model_name.param_key}.#{field}",
    scope: label_scope,
    default: [:"defaults.#{field}", field.to_s.humanize]).presence
end

#value(field_name, locals = {}) ⇒ Object


10
11
12
# File 'app/presenters/hyrax/presenter_renderer.rb', line 10

def value(field_name, locals = {})
  render_show_field_partial(field_name, locals)
end