Class: Nav::Builder
- Inherits:
-
Object
- Object
- Nav::Builder
- Defined in:
- lib/nav/builder.rb
Instance Method Summary collapse
- #action(name = nil, options = {}, html_options = {}) ⇒ Object
-
#initialize(template, options = {}) {|_self| ... } ⇒ Builder
constructor
A new instance of Builder.
- #to_s ⇒ Object
Constructor Details
#initialize(template, options = {}) {|_self| ... } ⇒ Builder
Returns a new instance of Builder.
3 4 5 6 7 8 |
# File 'lib/nav/builder.rb', line 3 def initialize( template, = {} ) @template, @options = template, @actions = [] yield self if block_given? end |
Instance Method Details
#action(name = nil, options = {}, html_options = {}) ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/nav/builder.rb', line 22 def action( name = nil, = {}, = {} ) @actions << if block_given? [ yield, name || {}, {} ] else = { :current => .delete(:current), :disabled => .delete(:disabled), :force_current => .delete(:force_current), :prepend => .delete(:prepend), :append => .delete(:append) } [ link_to(name, , ), , ] end end |
#to_s ⇒ Object
38 39 40 |
# File 'lib/nav/builder.rb', line 38 def to_s content_tag( :ul, actions.html_safe, @options ).html_safe if actions? end |