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(*args) ⇒ 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.
67 68 69 |
# File 'lib/cell/rails.rb', line 67 def cache_store # we want to use DI to set a cache store in cell/rails. ::ActionController::Base.cache_store end |
#call ⇒ Object
54 55 56 |
# File 'lib/cell/rails.rb', line 54 def call(*) super.html_safe end |
#form_authenticity_token(*args) ⇒ Object
81 82 83 |
# File 'lib/cell/rails.rb', line 81 def form_authenticity_token(*args) controller.send(:form_authenticity_token, *args) end |
#parent_controller ⇒ Object Also known as: controller
58 59 60 |
# File 'lib/cell/rails.rb', line 58 def parent_controller context[:controller] end |
#perform_caching? ⇒ Boolean
63 64 65 |
# File 'lib/cell/rails.rb', line 63 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
77 78 79 |
# File 'lib/cell/rails.rb', line 77 def protect_against_forgery? controller.send(:protect_against_forgery?) end |