Class: Aerogel::Admin::TabsBuilder
- Inherits:
-
Render::BlockHelper
- Object
- Render::BlockHelper
- Aerogel::Admin::TabsBuilder
- Defined in:
- lib/aerogel/admin/tabs_builder.rb
Overview
TabsBuilder constructs and displays a tab navigation. from passed object.
Example:
tabs do
tab "/url/to/page1", label: "Page 1"
tab "/url/to/page2", label: "Page 2"
end
Defined Under Namespace
Classes: Tab
Constant Summary collapse
- DEFAULT_OPTIONS =
{ style: 'standard' }
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
-
#style ⇒ Object
Returns the value of attribute style.
-
#tabs ⇒ Object
Returns the value of attribute tabs.
Instance Method Summary collapse
-
#initialize(options = {}, &block) ⇒ TabsBuilder
constructor
A new instance of TabsBuilder.
- #tab(*args, &block) ⇒ Object
- #template(name) ⇒ Object
- #wrap(content) ⇒ Object
Constructor Details
#initialize(options = {}, &block) ⇒ TabsBuilder
Returns a new instance of TabsBuilder.
20 21 22 23 24 25 |
# File 'lib/aerogel/admin/tabs_builder.rb', line 20 def initialize( = {}, &block ) super( &block ) self. = DEFAULT_OPTIONS.deep_merge( ) self.style = self.[:style] self.tabs = [] end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
14 15 16 |
# File 'lib/aerogel/admin/tabs_builder.rb', line 14 def @options end |
#style ⇒ Object
Returns the value of attribute style.
14 15 16 |
# File 'lib/aerogel/admin/tabs_builder.rb', line 14 def style @style end |
#tabs ⇒ Object
Returns the value of attribute tabs.
14 15 16 |
# File 'lib/aerogel/admin/tabs_builder.rb', line 14 def tabs @tabs end |
Instance Method Details
#tab(*args, &block) ⇒ Object
27 28 29 30 |
# File 'lib/aerogel/admin/tabs_builder.rb', line 27 def tab( *args, &block ) self.tabs << Tab.new( *args, &block ) nil end |
#template(name) ⇒ Object
32 33 34 |
# File 'lib/aerogel/admin/tabs_builder.rb', line 32 def template( name ) "admin/tabs_builder/#{style}/#{name}".to_sym end |
#wrap(content) ⇒ Object
36 37 38 |
# File 'lib/aerogel/admin/tabs_builder.rb', line 36 def wrap( content ) erb template("tabs.html"), locals: { tabs: self }, layout: false end |