Class: Georgia::MediaLibraryPresenter

Inherits:
Object
  • Object
show all
Defined in:
app/presenters/georgia/media_library_presenter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(view_context, imageable, args = {}) ⇒ MediaLibraryPresenter

Returns a new instance of MediaLibraryPresenter.



8
9
10
11
12
13
# File 'app/presenters/georgia/media_library_presenter.rb', line 8

def initialize view_context, imageable, args={}
  @view_context = view_context
  @imageable = imageable
  @target = args.fetch(:target, 'media_library_image')
  @input = args.fetch(:input, image_input_tag)
end

Instance Attribute Details

#view_contextObject

Returns the value of attribute view_context.



4
5
6
# File 'app/presenters/georgia/media_library_presenter.rb', line 4

def view_context
  @view_context
end

Instance Method Details

#choose_image_button_tagObject



21
22
23
# File 'app/presenters/georgia/media_library_presenter.rb', line 21

def choose_image_button_tag
  link_to("#{icon_tag('picture-o')} Choose Image".html_safe, '#', class: 'btn btn-primary js-media-library', data: {media: "##{@target}", toggle: 'modal', target: '#media_library'})
end

#imageObject



35
36
37
# File 'app/presenters/georgia/media_library_presenter.rb', line 35

def image
  @imageable.image
end

#image_idObject



39
40
41
# File 'app/presenters/georgia/media_library_presenter.rb', line 39

def image_id
  @imageable.image_id
end

#image_input_tagObject



31
32
33
# File 'app/presenters/georgia/media_library_presenter.rb', line 31

def image_input_tag
  hidden_field_tag(:image, image_id)
end


25
26
27
28
29
# File 'app/presenters/georgia/media_library_presenter.rb', line 25

def media_featured_tag
   :div, class: 'media-featured js-media-image' do
    picture_tag(image, format: :thumb)
  end
end

#to_sObject



15
16
17
18
19
# File 'app/presenters/georgia/media_library_presenter.rb', line 15

def to_s
  (:div, class: 'media-library-image', id: @target) do
    media_featured_tag + choose_image_button_tag + @input
  end
end