Class: V2Users::BaseController

Inherits:
ApplicationV2Controller show all
Includes:
AdminHelper, LogrageCustomLogger, ResponseCacheConcern, Trailblazer::Rails::Controller, Trailblazer::Rails::Controller::Cell, Trailblazer::Rails::Controller::Cell::Render, Trailblazer::Rails::Controller::Result, UpdateLocaleConcern
Defined in:
app/controllers/v2_users/base_controller.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from LogrageCustomLogger

#append_info_to_payload

Methods included from UpdateLocaleConcern

#setup_locale

Methods included from ResponseCacheConcern

#my_response_cache

Methods included from AdminHelper

#dynamic_pricings_formatter, #link_to_admin_reservations_path_by_id, #link_to_admin_restaurants_path_by_id, #link_to_log, #optional_locales, #optional_locales_with_labels, #staff_signed_in?

Class Method Details

.default_url_options(options = {}) ⇒ Object



81
82
83
# File 'app/controllers/v2_users/base_controller.rb', line 81

def self.default_url_options(options = {})
  (I18n.locale.to_sym.eql?(I18n.default_locale.to_sym) ? {} : { locale: I18n.locale }).merge options
end

Instance Method Details

#activate_cache?(cache_key, options = {}) ⇒ Boolean

TODO: rename to `by_pass_cache?` use __cache=false to by pass cache

Returns:

  • (Boolean)


87
88
89
90
91
92
93
94
95
# File 'app/controllers/v2_users/base_controller.rb', line 87

def activate_cache?(cache_key, options = {})
  return true if params[:__cache] == 'false'

  if cache_key.is_a?(Hash) && cache_key[:etag].present?
    options = cache_key.dup
    cache_key = options.delete(:etag)
  end
  stale?(cache_key, options)
end

#current_user_ckObject



97
98
99
# File 'app/controllers/v2_users/base_controller.rb', line 97

def current_user_ck
  user_signed_in? ? current_user.cache_key : ''
end

#identity_cache_memoization(&block) ⇒ Object



22
23
24
# File 'app/controllers/v2_users/base_controller.rb', line 22

def identity_cache_memoization(&block)
  IdentityCache.cache.with_memoization(&block)
end

#set_csrf_tokenObject



28
29
30
31
32
33
34
# File 'app/controllers/v2_users/base_controller.rb', line 28

def set_csrf_token
  cookies[:csrftoken] = {
    value: form_authenticity_token,
    expires: 1.day.from_now
    # secure: Rails.env.production? ? true : false
  }
end