zlw/action_presenter — pull request #5 by zlw (2012-02-20 21:35:46+00:00)
Title: Fix present helper

Fixed #present view helper. It now returns presenter instance if block is not given. It's now possible to easly use it in controller.

### Example

#### Object (model)

```ruby
class Foo
def foo
'foo'
end

def bar
'bar'
end

def foobar
'foobar' * 3
end
end
```

#### Presenter

```ruby
class FooPresenter < ActionPresenter::Base
presents :foo

@@user_attributes = [:foo, :foobar]
@@admin_attributes = [:foo, :bar, :foobar]

def index
attrs = current_user.admin? ? @@admin_attributes : @@user_attributes
Hash[*attrs.map {|attr| [attr, foo.send(attr)]}.flatten]
end
end
```

#### Controller

```ruby
class FooController < ApplicationController
respond_to :json, :xml

def index
respond_with present(Foo.new).index
end
end
```