Class: TabsOnRails::Tabs
- Inherits:
-
Object
- Object
- TabsOnRails::Tabs
- Defined in:
- lib/tabs_on_rails/tabs.rb,
lib/tabs_on_rails/tabs/builder.rb,
lib/tabs_on_rails/tabs/tabs_builder.rb
Defined Under Namespace
Classes: Builder, TabsBuilder
Class Attribute Summary collapse
Instance Method Summary collapse
-
#initialize(context, options = {}) ⇒ Tabs
constructor
A new instance of Tabs.
- #method_missing(*args, &block) ⇒ Object
-
#render(&block) ⇒ Object
Renders the tab stack using the current builder.
Constructor Details
#initialize(context, options = {}) ⇒ Tabs
Returns a new instance of Tabs.
25 26 27 28 29 |
# File 'lib/tabs_on_rails/tabs.rb', line 25 def initialize(context, = {}) @context = context @builder = (.delete(:builder) || self.class.default_builder).new(@context, ) @options = end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(*args, &block) ⇒ Object
42 43 44 |
# File 'lib/tabs_on_rails/tabs.rb', line 42 def method_missing(*args, &block) @builder.tab_for(*args, &block) end |
Class Attribute Details
.default_builder ⇒ Object
20 21 22 |
# File 'lib/tabs_on_rails/tabs.rb', line 20 def default_builder @default_builder ||= TabsBuilder end |
Instance Method Details
#render(&block) ⇒ Object
Renders the tab stack using the current builder.
Returns the String HTML content.
50 51 52 53 54 55 56 57 58 59 60 61 62 |
# File 'lib/tabs_on_rails/tabs.rb', line 50 def render(&block) raise LocalJumpError, "no block given" unless block_given? = @options.dup = .delete(:open_tabs) || {} = .delete(:close_tabs) || {} "".tap do |html| html << open_tabs().to_s html << @context.capture(self, &block) html << close_tabs().to_s end.html_safe end |