Class: Searls::Auth::HelperMethods
- Inherits:
-
Object
- Object
- Searls::Auth::HelperMethods
- Defined in:
- app/helpers/searls/auth/application_helper.rb
Instance Method Summary collapse
- #attr_for(model, field_name) ⇒ Object
- #email_field_stimulus_data ⇒ Object
- #enable_turbo? ⇒ Boolean
-
#initialize(view_context) ⇒ HelperMethods
constructor
A new instance of HelperMethods.
- #login_path(**kwargs) ⇒ Object
- #login_stimulus_controller ⇒ Object
- #login_url(**kwargs) ⇒ Object
- #otp_field_stimulus_data ⇒ Object
- #otp_stimulus_controller ⇒ Object
- #password_reset_available? ⇒ Boolean
- #password_reset_request_path(**kwargs) ⇒ Object
- #register_path(**kwargs) ⇒ Object
- #register_url(**kwargs) ⇒ Object
- #routes ⇒ Object
- #rpad(s, spacer = " ", times = 1) ⇒ Object
Constructor Details
#initialize(view_context) ⇒ HelperMethods
Returns a new instance of HelperMethods.
4 5 6 |
# File 'app/helpers/searls/auth/application_helper.rb', line 4 def initialize(view_context) @view_context = view_context end |
Instance Method Details
#attr_for(model, field_name) ⇒ Object
61 62 63 64 65 |
# File 'app/helpers/searls/auth/application_helper.rb', line 61 def attr_for(model, field_name) if model.respond_to?(field_name) model.send(field_name) end end |
#email_field_stimulus_data ⇒ Object
40 41 42 43 44 |
# File 'app/helpers/searls/auth/application_helper.rb', line 40 def email_field_stimulus_data { action: "change->searls-auth-login#updateEmail" } end |
#enable_turbo? ⇒ Boolean
57 58 59 |
# File 'app/helpers/searls/auth/application_helper.rb', line 57 def enable_turbo? params[:redirect_subdomain].blank? || params[:redirect_subdomain] == request.subdomain end |
#login_path(**kwargs) ⇒ Object
12 13 14 |
# File 'app/helpers/searls/auth/application_helper.rb', line 12 def login_path(**kwargs) routes.login_path(forwardable_params.merge(kwargs)) end |
#login_stimulus_controller ⇒ Object
36 37 38 |
# File 'app/helpers/searls/auth/application_helper.rb', line 36 def login_stimulus_controller "searls-auth-login" end |
#login_url(**kwargs) ⇒ Object
16 17 18 |
# File 'app/helpers/searls/auth/application_helper.rb', line 16 def login_url(**kwargs) routes.login_url(forwardable_params.merge(kwargs)) end |
#otp_field_stimulus_data ⇒ Object
50 51 52 53 54 55 |
# File 'app/helpers/searls/auth/application_helper.rb', line 50 def otp_field_stimulus_data { action: "paste->searls-auth-otp#pasted input->otp#caret click->searls-auth-otp#caret keydown->searls-auth-otp#caret keyup->searls-auth-otp#caret", searls_auth_otp_target: "input" } end |
#otp_stimulus_controller ⇒ Object
46 47 48 |
# File 'app/helpers/searls/auth/application_helper.rb', line 46 def otp_stimulus_controller "searls-auth-otp" end |
#password_reset_available? ⇒ Boolean
32 33 34 |
# File 'app/helpers/searls/auth/application_helper.rb', line 32 def password_reset_available? Searls::Auth.config.password_reset_enabled? end |
#password_reset_request_path(**kwargs) ⇒ Object
28 29 30 |
# File 'app/helpers/searls/auth/application_helper.rb', line 28 def password_reset_request_path(**kwargs) routes.password_reset_request_path(forwardable_params.merge(kwargs)) end |
#register_path(**kwargs) ⇒ Object
20 21 22 |
# File 'app/helpers/searls/auth/application_helper.rb', line 20 def register_path(**kwargs) routes.register_path(forwardable_params.merge(kwargs)) end |
#register_url(**kwargs) ⇒ Object
24 25 26 |
# File 'app/helpers/searls/auth/application_helper.rb', line 24 def register_url(**kwargs) routes.register_url(forwardable_params.merge(kwargs)) end |
#routes ⇒ Object
8 9 10 |
# File 'app/helpers/searls/auth/application_helper.rb', line 8 def routes Searls::Auth::Engine.routes.url_helpers end |
#rpad(s, spacer = " ", times = 1) ⇒ Object
67 68 69 70 |
# File 'app/helpers/searls/auth/application_helper.rb', line 67 def rpad(s, spacer = " ", times = 1) return "" if s.blank? "#{s}#{spacer * times}" end |