Class: HrLite::Configuration
- Inherits:
-
Object
- Object
- HrLite::Configuration
- Defined in:
- lib/hr_lite/configuration.rb
Overview
All host integration points. Every attribute has a working default so the engine boots in any Rails app; a real host overrides what it needs in an initializer. See README for the full annotated example.
Instance Attribute Summary collapse
-
#admin_check ⇒ Object
Returns the value of attribute admin_check.
-
#authenticate_method ⇒ Object
Returns the value of attribute authenticate_method.
-
#back_link ⇒ Object
Returns the value of attribute back_link.
-
#company ⇒ Object
Returns the value of attribute company.
-
#currency_symbol ⇒ Object
Returns the value of attribute currency_symbol.
-
#current_user_method ⇒ Object
Returns the value of attribute current_user_method.
-
#display_name_method ⇒ Object
Returns the value of attribute display_name_method.
-
#employees_scope ⇒ Object
Returns the value of attribute employees_scope.
-
#extra_stylesheets ⇒ Object
Returns the value of attribute extra_stylesheets.
-
#invite_url_for ⇒ Object
Returns the value of attribute invite_url_for.
-
#leadership_check ⇒ Object
Returns the value of attribute leadership_check.
-
#leadership_emails ⇒ Object
Returns the value of attribute leadership_emails.
-
#leave_year_start_month ⇒ Object
Returns the value of attribute leave_year_start_month.
-
#mailer_from ⇒ Object
Returns the value of attribute mailer_from.
-
#mentionable_users ⇒ Object
Returns the value of attribute mentionable_users.
-
#notification_matrix ⇒ Object
Returns the value of attribute notification_matrix.
-
#notify ⇒ Object
Returns the value of attribute notify.
-
#offboard_user ⇒ Object
Returns the value of attribute offboard_user.
-
#on_designation_change ⇒ Object
Returns the value of attribute on_designation_change.
-
#onboard_user ⇒ Object
Returns the value of attribute onboard_user.
-
#parent_controller ⇒ Object
Returns the value of attribute parent_controller.
-
#public_url_base ⇒ Object
(also: #mail_link_base)
Returns the value of attribute public_url_base.
-
#render_pdf ⇒ Object
Returns the value of attribute render_pdf.
-
#time_zone ⇒ Object
Returns the value of attribute time_zone.
-
#user_class ⇒ Object
Returns the value of attribute user_class.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/hr_lite/configuration.rb', line 32 def initialize @user_class = "User" @parent_controller = "ActionController::Base" @current_user_method = :current_user @authenticate_method = :authenticate_user! @admin_check = ->(user) { user.respond_to?(:admin?) && user.admin? } @display_name_method = :display_name @employees_scope = -> { HrLite.user_klass.all } @mentionable_users = ->(query) { HrLite.default_mentionable_users(query) } @notify = ->(user:, kind:, title:, body:, path:) { } @render_pdf = nil @company = -> { { name: "Company", address: nil, logo_path: nil } } @time_zone = "Asia/Kolkata" @currency_symbol = "₹" @on_designation_change = ->(user, designation) { } @leadership_emails = [] @leadership_check = ->(user) do emails = HrLite.config.leadership_emails.map { |e| e.to_s.downcase.strip } emails.include?(user.email.to_s.downcase) end @extra_stylesheets = [] # host stylesheets linked AFTER hr_lite.css (CSS-var overrides) @mailer_from = "hr@example.com" @public_url_base = nil # e.g. "https://hr.example.com" — enables email links + HrLite.public_url @notification_matrix = nil # resolved lazily to Notifications::DEFAULT_MATRIX @back_link = nil # optional {label:, url:} for the shell nav @leave_year_start_month = 1 # 1 = calendar year; 7 = July–June leave year # Leadership onboarding/offboarding. onboard_user must return a saved # user record (default: create on user_class with whatever of # name/email/password it supports). offboard_user should revoke the # person's access — the engine never deletes anything (statutory # records), it only stamps the exit date. @onboard_user = ->(name:, email:, password:) { klass = HrLite.user_klass attributes = { email: email } attributes[:name] = name if klass.column_names.include?("name") if klass.method_defined?(:password=) attributes[:password] = password attributes[:password_confirmation] = password if klass.method_defined?(:password_confirmation=) end klass.create!(attributes) } @offboard_user = ->(user) { } # Optional: return an absolute set-your-password URL for a freshly # onboarded user (e.g. a Devise reset link). When present, the welcome # email carries it and leadership never needs to hand over a password. @invite_url_for = nil end |
Instance Attribute Details
#admin_check ⇒ Object
Returns the value of attribute admin_check.
6 7 8 |
# File 'lib/hr_lite/configuration.rb', line 6 def admin_check @admin_check end |
#authenticate_method ⇒ Object
Returns the value of attribute authenticate_method.
6 7 8 |
# File 'lib/hr_lite/configuration.rb', line 6 def authenticate_method @authenticate_method end |
#back_link ⇒ Object
Returns the value of attribute back_link.
6 7 8 |
# File 'lib/hr_lite/configuration.rb', line 6 def back_link @back_link end |
#company ⇒ Object
Returns the value of attribute company.
6 7 8 |
# File 'lib/hr_lite/configuration.rb', line 6 def company @company end |
#currency_symbol ⇒ Object
Returns the value of attribute currency_symbol.
6 7 8 |
# File 'lib/hr_lite/configuration.rb', line 6 def currency_symbol @currency_symbol end |
#current_user_method ⇒ Object
Returns the value of attribute current_user_method.
6 7 8 |
# File 'lib/hr_lite/configuration.rb', line 6 def current_user_method @current_user_method end |
#display_name_method ⇒ Object
Returns the value of attribute display_name_method.
6 7 8 |
# File 'lib/hr_lite/configuration.rb', line 6 def display_name_method @display_name_method end |
#employees_scope ⇒ Object
Returns the value of attribute employees_scope.
6 7 8 |
# File 'lib/hr_lite/configuration.rb', line 6 def employees_scope @employees_scope end |
#extra_stylesheets ⇒ Object
Returns the value of attribute extra_stylesheets.
6 7 8 |
# File 'lib/hr_lite/configuration.rb', line 6 def extra_stylesheets @extra_stylesheets end |
#invite_url_for ⇒ Object
Returns the value of attribute invite_url_for.
6 7 8 |
# File 'lib/hr_lite/configuration.rb', line 6 def invite_url_for @invite_url_for end |
#leadership_check ⇒ Object
Returns the value of attribute leadership_check.
6 7 8 |
# File 'lib/hr_lite/configuration.rb', line 6 def leadership_check @leadership_check end |
#leadership_emails ⇒ Object
Returns the value of attribute leadership_emails.
6 7 8 |
# File 'lib/hr_lite/configuration.rb', line 6 def leadership_emails @leadership_emails end |
#leave_year_start_month ⇒ Object
Returns the value of attribute leave_year_start_month.
14 15 16 |
# File 'lib/hr_lite/configuration.rb', line 14 def leave_year_start_month @leave_year_start_month end |
#mailer_from ⇒ Object
Returns the value of attribute mailer_from.
6 7 8 |
# File 'lib/hr_lite/configuration.rb', line 6 def mailer_from @mailer_from end |
#mentionable_users ⇒ Object
Returns the value of attribute mentionable_users.
6 7 8 |
# File 'lib/hr_lite/configuration.rb', line 6 def mentionable_users @mentionable_users end |
#notification_matrix ⇒ Object
Returns the value of attribute notification_matrix.
6 7 8 |
# File 'lib/hr_lite/configuration.rb', line 6 def notification_matrix @notification_matrix end |
#notify ⇒ Object
Returns the value of attribute notify.
6 7 8 |
# File 'lib/hr_lite/configuration.rb', line 6 def notify @notify end |
#offboard_user ⇒ Object
Returns the value of attribute offboard_user.
6 7 8 |
# File 'lib/hr_lite/configuration.rb', line 6 def offboard_user @offboard_user end |
#on_designation_change ⇒ Object
Returns the value of attribute on_designation_change.
6 7 8 |
# File 'lib/hr_lite/configuration.rb', line 6 def on_designation_change @on_designation_change end |
#onboard_user ⇒ Object
Returns the value of attribute onboard_user.
6 7 8 |
# File 'lib/hr_lite/configuration.rb', line 6 def onboard_user @onboard_user end |
#parent_controller ⇒ Object
Returns the value of attribute parent_controller.
6 7 8 |
# File 'lib/hr_lite/configuration.rb', line 6 def parent_controller @parent_controller end |
#public_url_base ⇒ Object Also known as: mail_link_base
Returns the value of attribute public_url_base.
6 7 8 |
# File 'lib/hr_lite/configuration.rb', line 6 def public_url_base @public_url_base end |
#render_pdf ⇒ Object
Returns the value of attribute render_pdf.
6 7 8 |
# File 'lib/hr_lite/configuration.rb', line 6 def render_pdf @render_pdf end |
#time_zone ⇒ Object
Returns the value of attribute time_zone.
6 7 8 |
# File 'lib/hr_lite/configuration.rb', line 6 def time_zone @time_zone end |
#user_class ⇒ Object
Returns the value of attribute user_class.
6 7 8 |
# File 'lib/hr_lite/configuration.rb', line 6 def user_class @user_class end |