class TabsOnRails::Tabs::Builder

Builder

The Builder class represents the interface for any custom Builder.

To create a custom Builder, extend this class and implement the following abstract methods:

Optionally, you can override the following methods to customize the Builder behavior:

Public Class Methods

new(context, options = {}) click to toggle source

Initializes a new builder with the given hash of options, providing the current Rails template as context.

Warning: You should not override this method to prevent incompatibility with future versions.

# File lib/tabs_on_rails/tabs/builder.rb, line 35
def initialize(context, options = {})
  @context   = context
  @namespace = options.delete(:namespace) || :default
  @options   = options
end

Public Instance Methods

close_tabs(*args) click to toggle source

Override this method to use a custom close tag for your tabs.

# File lib/tabs_on_rails/tabs/builder.rb, line 71
def close_tabs(*args)
end
current_tab?(tab) click to toggle source

Returns true if tab is the current_tab.

Examples

class MyController < ApplicationController
  tab :foo
end

current_tab? :foo   # => true
current_tab? 'foo'  # => true
current_tab? :bar   # => false
current_tab? 'bar'  # => false
# File lib/tabs_on_rails/tabs/builder.rb, line 54
def current_tab?(tab)
  tab.to_s == @context.current_tab(@namespace).to_s
end
open_tabs(*args) click to toggle source

Override this method to use a custom open tag for your tabs.

# File lib/tabs_on_rails/tabs/builder.rb, line 67
def open_tabs(*args)
end
tab_for(*args) click to toggle source

Creates and returns a tab with given args.

Raises NotImplemented: you should implement this method in your custom Builder.

# File lib/tabs_on_rails/tabs/builder.rb, line 62
def tab_for(*args)
  raise NotImplementedError
end