Sha256: b6b23727c2fd31a09883f3fb8d0fe9947a4a29d3bd93517ba808a45af720a699

Contents?: true

Size: 826 Bytes

Versions: 2

Compression:

Stored size: 826 Bytes

Contents

module LayMeOut
  module Controllers
    module Navigation
      extend ActiveSupport::Concern

      def active_page?(path)
        path = normalized_path(path)
        current_page?(path) || active_pages.include?(path)
      end

      private

      def active_pages
        @active_pages ||= []
      end

      def activate_page(path)
        path = normalized_path(path)
        active_pages << path
      end

      def current_page?(options)
        url_string = CGI.escapeHTML(url_for(options))
        if url_string =~ /^\w+:\/\//
          url_string == "#{request.protocol}#{request.host_with_port}#{request.fullpath}"
        else
          url_string == request.fullpath
        end
      end

      def normalized_path(path)
        path.is_a?(Array) ? polymorphic_path(path) : path
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
lay_me_out-1.2.9 lib/lay_me_out/controllers/navigation.rb
lay_me_out-1.2.8 lib/lay_me_out/controllers/navigation.rb