Sha256: 52dcfef8afa1fdc3bd5f9a0fe700533479db61799b347e3d0618459f026ffa7d

Contents?: true

Size: 1.38 KB

Versions: 18

Compression:

Stored size: 1.38 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] : nil

          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] : nil

          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

18 entries across 18 versions & 2 rubygems

Version Path
blaxter-lockdown-0.9.8.99 lib/lockdown/frameworks/rails/view.rb
blaxter-lockdown-0.9.9 lib/lockdown/frameworks/rails/view.rb
lockdown-1.0.0 lib/lockdown/frameworks/rails/view.rb
lockdown-1.0.1 lib/lockdown/frameworks/rails/view.rb
lockdown-1.0.2 lib/lockdown/frameworks/rails/view.rb
lockdown-1.0.3 lib/lockdown/frameworks/rails/view.rb
lockdown-1.0.4 lib/lockdown/frameworks/rails/view.rb
lockdown-1.0.5 lib/lockdown/frameworks/rails/view.rb
lockdown-1.0.6 lib/lockdown/frameworks/rails/view.rb
lockdown-0.8.1 lib/lockdown/frameworks/rails/view.rb
lockdown-0.8.0 lib/lockdown/frameworks/rails/view.rb
lockdown-0.9.0 lib/lockdown/frameworks/rails/view.rb
lockdown-0.9.3 lib/lockdown/frameworks/rails/view.rb
lockdown-0.9.7 lib/lockdown/frameworks/rails/view.rb
lockdown-0.9.5 lib/lockdown/frameworks/rails/view.rb
lockdown-0.9.1 lib/lockdown/frameworks/rails/view.rb
lockdown-0.9.2 lib/lockdown/frameworks/rails/view.rb
lockdown-0.9.8 lib/lockdown/frameworks/rails/view.rb