Class: Jquelpers::TabsHelper::TabsRenderer

Inherits:
Object
  • Object
show all
Defined in:
lib/jquelpers/tabs_helper.rb

Instance Method Summary collapse

Constructor Details

#initialize(options = {}) {|_self| ... } ⇒ TabsRenderer

Returns a new instance of TabsRenderer.

Yields:

  • (_self)

Yield Parameters:

Raises:

  • (ArgumentError)


18
19
20
21
22
23
24
25
26
# File 'lib/jquelpers/tabs_helper.rb', line 18

def initialize( options={}, &block )
  raise ArgumentError, "Missing block" unless block_given?

  @template = eval( 'self', block.binding )
  @options = options
  @tabs = []

  yield self
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(*args, &block) ⇒ Object (private)



54
55
56
# File 'lib/jquelpers/tabs_helper.rb', line 54

def method_missing( *args, &block )
  @template.send( *args, &block )
end

Instance Method Details

#create(title, options = {}, &block) ⇒ Object



28
29
30
31
32
# File 'lib/jquelpers/tabs_helper.rb', line 28

def create( title, options={}, &block )
  raise "Block needed for TabsRenderer#CREATE" unless block_given?
  ajax = options.delete(:ajax)
  @tabs << [ @options[:id].to_s + "_" + @tabs.count.to_s, title, options, block, ajax ]
end

#renderObject



34
35
36
# File 'lib/jquelpers/tabs_helper.rb', line 34

def render
  ( :div, [render_tabs, render_bodies], { :id => @options[:id] })
end