Class: TabsHelper::TabsRenderer
- Inherits:
-
Object
- Object
- TabsHelper::TabsRenderer
show all
- Defined in:
- lib/helpers/tabs_helper.rb
Instance Method Summary
collapse
Constructor Details
#initialize(options = {}) {|_self| ... } ⇒ TabsRenderer
Returns a new instance of TabsRenderer.
12
13
14
15
16
17
18
19
20
|
# File 'lib/helpers/tabs_helper.rb', line 12
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
60
61
62
|
# File 'lib/helpers/tabs_helper.rb', line 60
def method_missing( *args, &block )
@template.send( *args, &block )
end
|
Instance Method Details
#create(tab_id, tab_text, options = {}, &block) ⇒ Object
22
23
24
25
|
# File 'lib/helpers/tabs_helper.rb', line 22
def create( tab_id, tab_text, options={}, &block )
raise "Block needed for TabsRenderer#CREATE" unless block_given?
@tabs << [ tab_id, tab_text, options, block, {:ajax => false} ]
end
|
#create_ajax(link, tab_text, options = {}) ⇒ Object
27
28
29
|
# File 'lib/helpers/tabs_helper.rb', line 27
def create_ajax( link, tab_text, options={})
@tabs << [ link, tab_text, options, nil, {:ajax => true} ]
end
|
#render ⇒ Object
31
32
33
|
# File 'lib/helpers/tabs_helper.rb', line 31
def render
content_tag( :div, raw([render_tabs, render_bodies].join), { :id => :tabs }.merge( @options ) )
end
|