module RedmineCrm class Settings SECTIONS = { 'money' => { id: :money, label: :label_redmine_crm_money, partial: 'money' } }.freeze class << self # Initialize settings before using with this method # @example # RedmineCrm::Settings.initialize_gem_settings def initialize_gem_settings return if Setting.respond_to?(:plugin_redmine_crm) Setting.send(:define_setting, 'plugin_redmine_crm', { 'default' => default_settings, 'serialized' => true }) end # Use apply instead attrs assign because it can rewrite other attributes def apply=(values) Setting.plugin_redmine_crm = Setting.plugin_redmine_crm.merge(values) end def values Object.const_defined?('Setting') ? Setting.plugin_redmine_crm : {} end def [](value) return Setting.plugin_redmine_crm[value] if Object.const_defined?('Setting') nil end private def default_settings {} end end end end