Sha256: db534c36f5d75bb1c1a97cb79603c41d6545443c623cdbc9eb7dd69166508e17

Contents?: true

Size: 1.39 KB

Versions: 22

Compression:

Stored size: 1.39 KB

Contents

module Lockdown
  module Frameworks
    module Rails
      module View
        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
    
        def link_to_secured(name, options = {}, html_options = nil)
          url = url_for(options)

          method = html_options ? html_options[:method] : :get

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

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

          method = html_options ? html_options[:method] : :get

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

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

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

Version data entries

22 entries across 22 versions & 3 rubygems

Version Path
hone-lockdown-1.2.1 lib/lockdown/frameworks/rails/view.rb
hone-lockdown-1.2.2 lib/lockdown/frameworks/rails/view.rb
hone-lockdown-1.2.3 lib/lockdown/frameworks/rails/view.rb
lockdown_vail-1.6.2.1 lib/lockdown/frameworks/rails/view.rb
lockdown-1.6.3 lib/lockdown/frameworks/rails/view.rb
lockdown-1.6.2 lib/lockdown/frameworks/rails/view.rb
lockdown-1.6.1 lib/lockdown/frameworks/rails/view.rb
lockdown-1.6.0 lib/lockdown/frameworks/rails/view.rb
lockdown-1.5.1 lib/lockdown/frameworks/rails/view.rb
lockdown-1.5.0 lib/lockdown/frameworks/rails/view.rb
lockdown-1.3.2 lib/lockdown/frameworks/rails/view.rb
lockdown-1.3.1 lib/lockdown/frameworks/rails/view.rb
lockdown-1.3.0 lib/lockdown/frameworks/rails/view.rb
lockdown-1.2.1 lib/lockdown/frameworks/rails/view.rb
lockdown-1.2.2 lib/lockdown/frameworks/rails/view.rb
lockdown-1.2.0 lib/lockdown/frameworks/rails/view.rb
lockdown-1.1.5 lib/lockdown/frameworks/rails/view.rb
lockdown-1.1.6 lib/lockdown/frameworks/rails/view.rb
lockdown-1.1.3 lib/lockdown/frameworks/rails/view.rb
lockdown-1.1.0 lib/lockdown/frameworks/rails/view.rb