Module: Xebec::ControllerSupport::ClassMethods

Defined in:
lib/xebec/controller_support.rb

Instance Method Summary collapse

Instance Method Details

Declare and populate a navigation bar. This method is a shorthand for creating a before_filter that looks up and populates a navigation bar.

Examples:

nav_bar :tabs, :only => [:index, :sent, :received, :new] do |nb|
  nb.nav_item :received, received_messages_path(current_user)
  nb.nav_item :sent,     sent_messages_path(current_user)
  nb.nav_item :new,      new_message_path
end

Parameters:

  • name (String, Symbol) (defaults to: Xebec::NavBar::DEFAULT_NAME)

    the name of the navigation bar; optional

  • options (Hash) (defaults to: {})

    the options for the before_filter; optional.

Yields:

  • (Xebec::NavBar)

    nav_bar the navigation bar – NB: does NOT yield at call-time, but at action run-time, as a before filter. The block is evaluated in the scope of the controller instance.

Returns:

  • (nil)


42
43
44
45
46
47
# File 'lib/xebec/controller_support.rb', line 42

def nav_bar(name = Xebec::NavBar::DEFAULT_NAME, options = {}, &block)
  append_before_filter options do |controller|
    controller.nav_bar name, &block
  end
  nil
end