Sha256: 13e41bdde3eb636473da70ed578818b4c1a4e300232f022bba9cf28ac75fd688

Contents?: true

Size: 887 Bytes

Versions: 3

Compression:

Stored size: 887 Bytes

Contents

module Authz
  module Helpers
    # View Helpers that are made available to the host application
    module ViewHelpers

      # Renders a link if user is authorized or does nothing otherwise
      # @param name [String] same as Rails link_to
      # @param options [Hash] same as Rails link_to
      # @param html_options [Hash] same as Rails link_to
      # @param using [Object] instance that will be used to determine authorization
      # @param skip_scoping [Boolean] option to skip scoping validation
      def authz_link_to(name, options = {}, html_options = {}, using: nil, skip_scoping: nil)
        url = url_for(options)
        method = html_options[:method] || html_options['method']
        authorized = authorized_path? url, method: method, using: using, skip_scoping: skip_scoping
        link_to(name, options, html_options) if authorized
      end

    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
authz-0.0.5 lib/authz/helpers/view_helpers.rb
authz-0.0.4 lib/authz/helpers/view_helpers.rb
authz-0.0.3 lib/authz/helpers/view_helpers.rb