Class: Viewable::LinkPresenter
Instance Attribute Summary
#context, #model
Instance Method Summary
collapse
#edit_link, #li_sortable_tag
#initialize, #method_missing, #respond_to?
Constructor Details
This class inherits a constructor from BasePresenter
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
in the class BasePresenter
Instance Method Details
#active?(options = {}) ⇒ Boolean
40
41
42
43
44
45
46
47
48
49
|
# File 'app/presenters/viewable/link_presenter.rb', line 40
def active?(options = {})
@active ||= begin
path = url(options)
if path == '#' || path[/^http/]
false
else
!!(h.request.path =~ /^#{path}/)
end
end
end
|
#li_link_to(name = nil, options = {}) ⇒ Object
7
8
9
10
11
|
# File 'app/presenters/viewable/link_presenter.rb', line 7
def li_link_to(name = nil, options = {})
li_sortable_tag options[:li] do
h.active_link_to *normalize_link_options(name, options)
end
end
|
#li_link_to_with_edit(name = nil, options = {}) ⇒ Object
13
14
15
16
17
18
|
# File 'app/presenters/viewable/link_presenter.rb', line 13
def li_link_to_with_edit(name = nil, options = {})
li_sortable_tag options[:li] do
h.concat h.active_link_to(*normalize_link_options(name, options))
h.concat edit_link
end
end
|
#link_to(name = nil, options = {}) ⇒ Object
3
4
5
|
# File 'app/presenters/viewable/link_presenter.rb', line 3
def link_to(name = nil, options = {})
h.active_link_to *normalize_link_options(name, options)
end
|
#url(options = {}) ⇒ Object
30
31
32
33
34
35
36
37
38
|
# File 'app/presenters/viewable/link_presenter.rb', line 30
def url(options = {})
@url ||= begin
if m.file.present?
h.main_app.file_path(id: m)
else
m.page.presence || m.url.presence || options[:path] || options[:url] || '#'
end
end
end
|
#youtube_embed_url(width = 420, height = 315) ⇒ Object
20
21
22
23
24
25
26
27
28
|
# File 'app/presenters/viewable/link_presenter.rb', line 20
def youtube_embed_url(width = 420, height = 315)
if (url = m.url)
link = YouTubeAddy.youtube_embed_url(url, width, height)
unless link[/\[\/\^/]
link.html_safe
end
end
end
|