Module: Hyrax::FileSetHelper

Included in:
BatchEditsController, HyraxHelperBehavior
Defined in:
app/helpers/hyrax/file_set_helper.rb

Instance Method Summary collapse

Instance Method Details

#media_display(presenter, locals = {}) ⇒ Object

REVIEW: Since this media display could theoretically work for

any object that inplements to_s and the Mime Type methos (image? audio? ...),
Should this really be in file_set or could it be in it's own helper class like media_helper?


13
14
15
16
# File 'app/helpers/hyrax/file_set_helper.rb', line 13

def media_display(presenter, locals = {})
  render media_display_partial(presenter),
         locals.merge(file_set: presenter)
end

#media_display_partial(file_set) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/helpers/hyrax/file_set_helper.rb', line 18

def media_display_partial(file_set)
  'hyrax/file_sets/media_display/' +
    if file_set.image?
      'image'
    elsif file_set.video?
      'video'
    elsif file_set.audio?
      'audio'
    elsif file_set.pdf?
      'pdf'
    elsif file_set.office_document?
      'office_document'
    else
      'default'
    end
end

#parent_path(parent) ⇒ Object



2
3
4
5
6
7
8
# File 'app/helpers/hyrax/file_set_helper.rb', line 2

def parent_path(parent)
  if parent.is_a?(Collection)
    main_app.collection_path(parent)
  else
    polymorphic_path([main_app, parent])
  end
end