Sha256: 6e664aa66991240b4b89d58a9530a7ac8f4f6835e79c462505ae05b68e2b022d

Contents?: true

Size: 602 Bytes

Versions: 1

Compression:

Stored size: 602 Bytes

Contents

module MenuBuilder
  module ViewHelpers
    class Tab

      def initialize(context)
        @context = context
        @current_tab = @context.instance_variable_get('@current_tab')
      end

      def current_tab?(tab)
        @current_tab.to_s == tab.to_s
      end

      def method_missing(tab, *args, &block)
        css_class = "current" if current_tab?(tab)
        @context.content_tag :li, @context.link_to(*args, &block), :class=>css_class
      end

    end

    def tabs(options={})
      concat tag(:ul, options, true)
      yield Tab.new(self)
      concat "</ul>"
    end
    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
menu_builder-0.0.2 lib/menu_builder/view.rb