Sha256: 867b80f4bccf3f59f5bade6d78560c6a6033ec36b0a8c53521f9aba5f969f5f3

Contents?: true

Size: 796 Bytes

Versions: 19

Compression:

Stored size: 796 Bytes

Contents

module Leather
  module ActionControllerExtension
    extend ActiveSupport::Concern

    included do
      extend        ClassMethods
      helper_method :current_tab, :current_tab?
    end

    protected

    def set_tab(name, namespace = nil)
      tab_stack[namespace || :default] = name
    end

    def current_tab(namespace = nil)
      tab_stack[namespace || :default]
    end

    def current_tab?(name, namespace = nil)
      current_tab(namespace).to_s == name.to_s
    end

    def tab_stack
      @tab_stack ||= {}
    end

    module ClassMethods
      def set_tab(*args)
        options = args.extract_options!
        name, namespace = args

        before_filter(options) do |controller|
          controller.send(:set_tab, name, namespace)
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
leather-3.5.1 lib/leather/action_controller_extension.rb
leather-3.5.0 lib/leather/action_controller_extension.rb
leather-3.3.5 lib/leather/action_controller_extension.rb
leather-3.3.4.1 lib/leather/action_controller_extension.rb
leather-3.3.4 lib/leather/action_controller_extension.rb
leather-3.3.3.4 lib/leather/action_controller_extension.rb
leather-3.3.3.3 lib/leather/action_controller_extension.rb
leather-3.3.3.2 lib/leather/action_controller_extension.rb
leather-3.3.3.1 lib/leather/action_controller_extension.rb
leather-3.3.2 lib/leather/action_controller_extension.rb
leather-3.3.1 lib/leather/action_controller_extension.rb
leather-3.3.0 lib/leather/action_controller_extension.rb
leather-3.2.0 lib/leather/action_controller_extension.rb
leather-0.2.29 lib/leather/action_controller_extension.rb
leather-0.2.27 lib/leather/action_controller_extension.rb
leather-0.2.26 lib/leather/action_controller_extension.rb
leather-0.2.25 lib/leather/action_controller_extension.rb
leather-0.2.24 lib/leather/action_controller_extension.rb
leather-0.2.23 lib/leather/action_controller_extension.rb