Module: Cell::RailsExtensions::ViewModel
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/cell/rails.rb
Overview
Gets included into Cell::ViewModel in a Rails environment.
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#cache_store ⇒ Object
we want to use DI to set a cache store in cell/rails.
- #call ⇒ Object
- #form_authenticity_token(**options) ⇒ Object
- #parent_controller ⇒ Object (also: #controller)
- #perform_caching? ⇒ Boolean
-
#protect_against_forgery? ⇒ Boolean
In Ruby 2.4.0+, Forwardable prints a warning when you delegate to a private or protected method - so ‘delegates :protect_against_forgery?` or `delegates :form_authenticity_token` will print warnings all over the place.
Instance Method Details
#cache_store ⇒ Object
we want to use DI to set a cache store in cell/rails.
68 69 70 |
# File 'lib/cell/rails.rb', line 68 def cache_store # we want to use DI to set a cache store in cell/rails. ::ActionController::Base.cache_store end |
#call ⇒ Object
55 56 57 |
# File 'lib/cell/rails.rb', line 55 def call(*) super.html_safe end |
#form_authenticity_token(**options) ⇒ Object
82 83 84 |
# File 'lib/cell/rails.rb', line 82 def form_authenticity_token(**) controller.send(:form_authenticity_token, **) end |
#parent_controller ⇒ Object Also known as: controller
59 60 61 |
# File 'lib/cell/rails.rb', line 59 def parent_controller context[:controller] end |
#perform_caching? ⇒ Boolean
64 65 66 |
# File 'lib/cell/rails.rb', line 64 def perform_caching? ::ActionController::Base.perform_caching end |
#protect_against_forgery? ⇒ Boolean
In Ruby 2.4.0+, Forwardable prints a warning when you delegate to a private or protected method - so ‘delegates :protect_against_forgery?` or `delegates :form_authenticity_token` will print warnings all over the place
This workaround prevents warnings being printed
78 79 80 |
# File 'lib/cell/rails.rb', line 78 def protect_against_forgery? controller.send(:protect_against_forgery?) end |