andi/simple-navigation — pull request #105 by ronalchn (2012-08-28 09:05:55+00:00)
Title: render_navigation takes block for ad-hoc menus

This pull request is a modification of https://github.com/andi/simple-navigation/pull/104.

As discussed, we want to allow ad-hoc menus with a block passed to render_navigation:

```ruby
render_navigation do |menu|
menu.item :statement, "Statement", problem_path(@problem)
menu.item :submit, "Submit", submit_problem_path(@problem) if can? :submit, @problem
end
```

To do this, some other methods were changed, most notably, the original support for a block in `active_navigation_item_container` removed.

```ruby
def active_navigation_item_container(options={})
# several lines of code here
container = SimpleNavigation.active_item_container_for(options[:level])
block_given? ? yield(container) : container # removed this line
end
```

The reason is that this functionality doesn't really add any value, so the original code which was passed as blocks (in methods `render_navigation` and `active_navigation_item`), were moved to execute after calling this method. The documentation does not mention the use of blocks with this method, so it is probably safe to change this.

The slot for a single block allowed in methods for `render_navigation`, `active_navigation_item_container` (block argument re-purposed) and `load_config`, is now used for this functionality.

Also:

* added a single rspec to ensure that the block is executed, and is given an ItemContainer argument.
* added a few lines of documentation on using a block with render_navigation