class Vizier::PresenterConfig
Mapping for a given type to presenter and policy types.
This configuration does not cache the constant lookups, so it supports reloading of the types in development. The CachingPresenterConfig
should be used in production.
Public Class Methods
new(type, presenter, policy)
click to toggle source
# File lib/vizier/presenter_config.rb, line 10 def initialize(type, presenter, policy) @type_name = type.to_s @presenter_name = presenter.to_s @policy_name = policy.to_s end
Public Instance Methods
policy()
click to toggle source
# File lib/vizier/presenter_config.rb, line 28 def policy Object.const_get(@policy_name) end
present(object, user, view)
click to toggle source
# File lib/vizier/presenter_config.rb, line 16 def present(object, user, view) presenter.new(policy.new(user, object), view) end
presenter()
click to toggle source
# File lib/vizier/presenter_config.rb, line 24 def presenter Object.const_get(@presenter_name) end
type()
click to toggle source
# File lib/vizier/presenter_config.rb, line 20 def type Object.const_get(@type_name) end