Sha256: cf43003f993157a6509352450233ff44d2df6c944fb3a0ed52c0ce117a799aec

Contents?: true

Size: 1 KB

Versions: 1

Compression:

Stored size: 1 KB

Contents

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

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
redmine_crm-0.0.48 lib/redmine_crm/settings.rb