Class: Vizier::PresenterConfig
- Inherits:
-
Object
- Object
- Vizier::PresenterConfig
- Defined in:
- lib/vizier/presenter_config.rb
Overview
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.
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(type, presenter, policy) ⇒ PresenterConfig
constructor
A new instance of PresenterConfig.
- #policy ⇒ Object
- #present(object, user, view) ⇒ Object
- #presenter ⇒ Object
- #type ⇒ Object
Constructor Details
#initialize(type, presenter, policy) ⇒ PresenterConfig
Returns a new instance of PresenterConfig.
10 11 12 13 14 |
# 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 |
Instance Method Details
#policy ⇒ Object
28 29 30 |
# File 'lib/vizier/presenter_config.rb', line 28 def policy Object.const_get(@policy_name) end |
#present(object, user, view) ⇒ Object
16 17 18 |
# File 'lib/vizier/presenter_config.rb', line 16 def present(object, user, view) presenter.new(policy.new(user, object), view) end |
#presenter ⇒ Object
24 25 26 |
# File 'lib/vizier/presenter_config.rb', line 24 def presenter Object.const_get(@presenter_name) end |
#type ⇒ Object
20 21 22 |
# File 'lib/vizier/presenter_config.rb', line 20 def type Object.const_get(@type_name) end |