Class: HrLite::Configuration

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

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_checkObject

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_methodObject

Returns the value of attribute authenticate_method.



6
7
8
# File 'lib/hr_lite/configuration.rb', line 6

def authenticate_method
  @authenticate_method
end

Returns the value of attribute back_link.



6
7
8
# File 'lib/hr_lite/configuration.rb', line 6

def back_link
  @back_link
end

#companyObject

Returns the value of attribute company.



6
7
8
# File 'lib/hr_lite/configuration.rb', line 6

def company
  @company
end

#currency_symbolObject

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_methodObject

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_methodObject

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_scopeObject

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_stylesheetsObject

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_forObject

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_checkObject

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_emailsObject

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_monthObject

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_fromObject

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_usersObject

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_matrixObject

Returns the value of attribute notification_matrix.



6
7
8
# File 'lib/hr_lite/configuration.rb', line 6

def notification_matrix
  @notification_matrix
end

#notifyObject

Returns the value of attribute notify.



6
7
8
# File 'lib/hr_lite/configuration.rb', line 6

def notify
  @notify
end

#offboard_userObject

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_changeObject

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_userObject

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_controllerObject

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_baseObject 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_pdfObject

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_zoneObject

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_classObject

Returns the value of attribute user_class.



6
7
8
# File 'lib/hr_lite/configuration.rb', line 6

def user_class
  @user_class
end