Module: Vicar::RailsExtensions::ActionView

Defined in:
lib/vicar/rails_extensions/action_view.rb

Instance Method Summary collapse

Instance Method Details

#presenter(name, action, *args) {|presenter| ... } ⇒ Object

Create presenter from app/presenters and call method

name - Symbol action - Symbol args - arguments for presenter method

Yields the presenter instance

Examples

- presenter :company, :awards, @company

Returns variant

Yields:



17
18
19
20
21
22
23
# File 'lib/vicar/rails_extensions/action_view.rb', line 17

def presenter(name, action, *args)
  presenter = "#{name.to_s.camelize}Presenter".constantize.new(self)

  yield(presenter) if block_given?

  presenter.send(action, *args)
end