Class: Aerogel::Admin::TabsBuilder

Inherits:
Render::BlockHelper
  • Object
show all
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

Instance Method Summary collapse

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( options = {}, &block )
  super( &block )
  self.options = DEFAULT_OPTIONS.deep_merge( options )
  self.style = self.options[:style]
  self.tabs = []
end

Instance Attribute Details

#optionsObject

Returns the value of attribute options.



14
15
16
# File 'lib/aerogel/admin/tabs_builder.rb', line 14

def options
  @options
end

#styleObject

Returns the value of attribute style.



14
15
16
# File 'lib/aerogel/admin/tabs_builder.rb', line 14

def style
  @style
end

#tabsObject

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