Class: Pageflow::CutoffModes
- Inherits:
-
Object
- Object
- Pageflow::CutoffModes
- Defined in:
- lib/pageflow/cutoff_modes.rb
Overview
Register strategies to determine whether only the part of an entry before some cutoff point should be rendered (e.g., to preview paywalled premium content).
Defined Under Namespace
Classes: Mode
Instance Method Summary collapse
- #enabled_for?(entry, request) ⇒ Boolean private
-
#initialize ⇒ CutoffModes
constructor
private
A new instance of CutoffModes.
- #names ⇒ Object private
-
#register(name, enabled) ⇒ Object
Register callable to determine whether only the part of an entry before some cutoff point should be rendered (e.g., to preview paywalled premium content).
Constructor Details
#initialize ⇒ CutoffModes
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.
Returns a new instance of CutoffModes.
8 9 10 |
# File 'lib/pageflow/cutoff_modes.rb', line 8 def initialize @modes = {} end |
Instance Method Details
#enabled_for?(entry, request) ⇒ Boolean
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.
27 28 29 |
# File 'lib/pageflow/cutoff_modes.rb', line 27 def enabled_for?(entry, request) !!@modes[entry.site.cutoff_mode_name]&.enabled&.call(entry, request) end |
#names ⇒ 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.
32 33 34 |
# File 'lib/pageflow/cutoff_modes.rb', line 32 def names @modes.keys end |
#register(name, enabled) ⇒ Object
Register callable to determine whether only the part of an entry before some cutoff point should be rendered (e.g., to preview paywalled premium content). Cutoff modes can then be enabled per site.
22 23 24 |
# File 'lib/pageflow/cutoff_modes.rb', line 22 def register(name, enabled) @modes[name.to_s] = Mode.new(name, enabled) end |