Module: Lotus::Presenter
- Included in:
- View::Escape::Presenter
- Defined in:
- lib/lotus/presenter.rb
Overview
Presenter pattern implementation
It delegates to the wrapped object the missing method invocations.
The output of concrete and delegated methods is escaped as XSS prevention.
Class Method Summary collapse
-
.included(base) ⇒ Object
private
Inject escape logic into the given class.
Instance Method Summary collapse
-
#initialize(object) ⇒ Object
Initialize the presenter.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(m, *args, &blk) ⇒ Object (protected)
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Override Ruby’s method_missing
110 111 112 113 114 115 116 |
# File 'lib/lotus/presenter.rb', line 110 def method_missing(m, *args, &blk) if @object.respond_to?(m) ::Lotus::View::Escape.html(@object.__send__(m, *args, &blk)) else super end end |
Class Method Details
.included(base) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Inject escape logic into the given class.
92 93 94 |
# File 'lib/lotus/presenter.rb', line 92 def self.included(base) base.extend ::Lotus::View::Escape end |
Instance Method Details
#initialize(object) ⇒ Object
Initialize the presenter
101 102 103 |
# File 'lib/lotus/presenter.rb', line 101 def initialize(object) @object = object end |