Sha256: 220ed6c982851303e0ca988223e29c5b0b1d849a6c6716b310208073d020b92a
Contents?: true
Size: 1.32 KB
Versions: 1
Compression:
Stored size: 1.32 KB
Contents
# frozen_string_literal: true # # helpers for core views # module CoreHelper # # Set the title for the page # def title(page_title) content_for(:title) { page_title } end def system_configuration_path '/' + [Web47core.config.system_configuration_namespace, 'system_configuration'].join('/') end def edit_system_configuration_path [system_configuration_path, 'edit'].join('/') end # # Pull the value from system configuration and mask the ones that match the given strings # def mask_system_configuration(field) should_mask = false %w[password token secret access_key api_key].each do |mask| should_mask |= field.include?(mask) end value = SystemConfiguration.send(field) should_mask ? mask_value(value, default: 'No Set') : value end # # Mask a value, i.e. password field # 1. If blank or nil, return the default # 2. Length of 1-4 only show the first character # 3. Length 5-10 only show the first and last character # 4. Otherwise show the first and last three characters def mask_value(value, default: '************') return default if value.blank? case value.length when 1..4 "#{value.first}***********" when 5..10 "#{value.first}**********#{value.last}" else "#{value[0..2]}**********#{value[-3..-1]}" end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
web47core-0.1.11 | lib/app/helpers/core_helper.rb |