Module: Lockdown::Frameworks::Rails::View

Defined in:
lib/lockdown/frameworks/rails/view.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



5
6
7
8
9
10
11
12
13
# File 'lib/lockdown/frameworks/rails/view.rb', line 5

def self.included(base)
  base.class_eval do
    alias_method :link_to_open, :link_to
    alias_method :link_to, :link_to_secured

    alias_method :button_to_open, :button_to
    alias_method :button_to, :button_to_secured
  end
end

Instance Method Details

#button_to_secured(name, options = {}, html_options = nil) ⇒ Object



26
27
28
29
30
31
32
33
34
35
# File 'lib/lockdown/frameworks/rails/view.rb', line 26

def button_to_secured(name, options = {}, html_options = nil)
  url = url_for(options)

  method = html_options ? html_options[:method] : nil

  if authorized?(url, method)
    return button_to_open(name, url, html_options)
  end
  return ""
end


37
38
39
40
# File 'lib/lockdown/frameworks/rails/view.rb', line 37

def link_to_or_show(name, options = {}, html_options = nil)
  lnk = link_to(name, options, html_options)
  lnk.length == 0 ? name : lnk
end


15
16
17
18
19
20
21
22
23
24
# File 'lib/lockdown/frameworks/rails/view.rb', line 15

def link_to_secured(name, options = {}, html_options = nil)
  url = url_for(options)

  method = html_options ? html_options[:method] : nil

  if authorized?(url, method)
    return link_to_open(name, url, html_options)
  end
  return ""
end


42
43
44
45
46
# File 'lib/lockdown/frameworks/rails/view.rb', line 42

def links(*lis)
  rvalue = []
  lis.each{|link| rvalue << link if link.length > 0 }
  rvalue.join( Lockdown::System.fetch(:link_separator) )
end