Class: TabsOnRails::Tabs::Builder
- Inherits:
-
Object
- Object
- TabsOnRails::Tabs::Builder
- Defined in:
- lib/tabs_on_rails/tabs.rb
Overview
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:
-
tab_for(args)
Direct Known Subclasses
Instance Method Summary collapse
-
#close_tabs ⇒ Object
Overwrite this method to use a custom close tag for your tabs.
-
#current_tab?(tab) ⇒ Boolean
Returns true if
tabis thecurrent_tab. -
#initialize(context, options = {}) ⇒ Builder
constructor
Initializes a new builder with
context. -
#open_tabs ⇒ Object
Overwrite this method to use a custom open tag for your tabs.
-
#tab_for(*args) ⇒ Object
Creates and returns a tab with given
args.
Constructor Details
#initialize(context, options = {}) ⇒ Builder
Initializes a new builder with context.
Note. You should not overwrite this method to prevent incompatibility with future versions.
36 37 38 39 |
# File 'lib/tabs_on_rails/tabs.rb', line 36 def initialize(context, = {}) @context = context @namespace = .delete(:namespace) || :default end |
Instance Method Details
#close_tabs ⇒ Object
Overwrite this method to use a custom close tag for your tabs.
74 75 |
# File 'lib/tabs_on_rails/tabs.rb', line 74 def close_tabs end |
#current_tab?(tab) ⇒ Boolean
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
54 55 56 |
# File 'lib/tabs_on_rails/tabs.rb', line 54 def current_tab?(tab) tab.to_s == @context.current_tab(@namespace).to_s end |
#open_tabs ⇒ Object
Overwrite this method to use a custom open tag for your tabs.
70 71 |
# File 'lib/tabs_on_rails/tabs.rb', line 70 def open_tabs end |
#tab_for(*args) ⇒ Object
Creates and returns a tab with given args.
Raises
- NotImplemented
-
you should implement this method in your custom Builder.
65 66 67 |
# File 'lib/tabs_on_rails/tabs.rb', line 65 def tab_for(*args) raise NotImplementedError end |