Class: Admix::Tab

Inherits:
Object
  • Object
show all
Defined in:
app/helpers/admix/tab.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(view_context, tab_name, tab_id = nil, options = {}) {|_self| ... } ⇒ Tab

Returns a new instance of Tab.

Yields:

  • (_self)

Yield Parameters:

  • _self (Admix::Tab)

    the object that the method was called on



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/helpers/admix/tab.rb', line 9

def initialize(view_context, tab_name, tab_id = nil, options={}, &block)
  @view_context ||= view_context
  @tab_id = "tab-#{tab_name}".parameterize.to_sym unless tab_id
  @tab_name = tab_name

  @options = options

  @header = view_context. :li, class: (options[:first] ? 'active' : '') do
    view_context.link_to(@tab_name, "##{@tab_id}")
  end

  @content = ''.html_safe
  yield(self)
end

Instance Attribute Details

#contentObject (readonly)

include ActionView::Helpers::CaptureHelper include ActionView::Helpers::TagHelper



7
8
9
# File 'app/helpers/admix/tab.rb', line 7

def content
  @content
end

#headerObject (readonly)

include ActionView::Helpers::CaptureHelper include ActionView::Helpers::TagHelper



7
8
9
# File 'app/helpers/admix/tab.rb', line 7

def header
  @header
end

#optionsObject (readonly)

include ActionView::Helpers::CaptureHelper include ActionView::Helpers::TagHelper



7
8
9
# File 'app/helpers/admix/tab.rb', line 7

def options
  @options
end

#tab_idObject (readonly)

include ActionView::Helpers::CaptureHelper include ActionView::Helpers::TagHelper



7
8
9
# File 'app/helpers/admix/tab.rb', line 7

def tab_id
  @tab_id
end

#view_contextObject (readonly)

include ActionView::Helpers::CaptureHelper include ActionView::Helpers::TagHelper



7
8
9
# File 'app/helpers/admix/tab.rb', line 7

def view_context
  @view_context
end

Instance Method Details

#tab_content(&block) ⇒ Object



28
29
30
# File 'app/helpers/admix/tab.rb', line 28

def tab_content(&block)
  @content =  block_given? ? @view_context.capture(&block) : ''
end

#tab_header(&block) ⇒ Object



24
25
26
# File 'app/helpers/admix/tab.rb', line 24

def tab_header(&block)
  @header = block_given? ? @view_context.capture(&block) : ''
end