class Vizier::ResourcePresenter

Base implementation for a Resource Presenter.

This class can be extended in your application to inherit the convenience of delegating to a policy's resource and having a default `present` method available for wrapping other objects according to the configured factory. To specify a factory, override `presenter_factory`.

Attributes

policy[R]
presenter_factory[R]
view[R]

Public Class Methods

new(policy, view, presenter_factory: PresenterFactory.new) click to toggle source
# File lib/vizier/resource_presenter.rb, line 13
def initialize(policy, view, presenter_factory: PresenterFactory.new)
  @policy = policy
  @view   = view
  @presenter_factory = presenter_factory
  __setobj__ policy.resource
end

Protected Instance Methods

present(object) click to toggle source
# File lib/vizier/resource_presenter.rb, line 26
def present(object)
  presenter_factory[object, policy.user, view]
end
resource() click to toggle source
# File lib/vizier/resource_presenter.rb, line 22
def resource
  policy.resource
end