Class: Searls::Auth::HelperMethods

Inherits:
Object
  • Object
show all
Defined in:
app/helpers/searls/auth/application_helper.rb

Instance Method Summary collapse

Constructor Details

#initialize(view_context) ⇒ 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



53
54
55
56
57
# File 'app/helpers/searls/auth/application_helper.rb', line 53

def attr_for(model, field_name)
  if model.respond_to?(field_name)
    model.send(field_name)
  end
end

#email_field_stimulus_dataObject



32
33
34
35
36
# File 'app/helpers/searls/auth/application_helper.rb', line 32

def email_field_stimulus_data
  {
    action: "change->searls-auth-login#updateEmail"
  }
end

#enable_turbo?Boolean



49
50
51
# File 'app/helpers/searls/auth/application_helper.rb', line 49

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 (**kwargs)
  routes.(forwardable_params.merge(kwargs))
end

#login_stimulus_controllerObject



28
29
30
# File 'app/helpers/searls/auth/application_helper.rb', line 28

def 
  "searls-auth-login"
end

#login_url(**kwargs) ⇒ Object



16
17
18
# File 'app/helpers/searls/auth/application_helper.rb', line 16

def (**kwargs)
  routes.(forwardable_params.merge(kwargs))
end

#otp_field_stimulus_dataObject



42
43
44
45
46
47
# File 'app/helpers/searls/auth/application_helper.rb', line 42

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_controllerObject



38
39
40
# File 'app/helpers/searls/auth/application_helper.rb', line 38

def otp_stimulus_controller
  "searls-auth-otp"
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

#routesObject



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



59
60
61
62
# File 'app/helpers/searls/auth/application_helper.rb', line 59

def rpad(s, spacer = " ", times = 1)
  return "" if s.blank?
  "#{s}#{spacer * times}"
end