Sha256: f80ac3f6d4846d8363e1783c57415960adb8360fdbe5c1402e1b4c45a25c4ea1

Contents?: true

Size: 665 Bytes

Versions: 8

Compression:

Stored size: 665 Bytes

Contents

# frozen_string_literal: true

require_dependency 'redmine_plugins_helper/available'

module RedminePluginsHelper
  class Settings
    class << self
      def default(plugin, default)
        return unless ::RedminePluginsHelper::Available.settings?

        p = plugin_current_setting_value(plugin)
        default.each do |k, v|
          p[k.to_s] = v unless p.key?(k)
        end
        ::Setting.send("plugin_#{plugin}=", p)
      end

      private

      def plugin_current_setting_value(plugin)
        p = ::Setting.send("plugin_#{plugin}")
        p = {} unless p.is_a?(::Hash)
        p = p.with_indifferent_access
        p
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
redmine_plugins_helper-0.13.2 lib/redmine_plugins_helper/settings.rb
redmine_plugins_helper-0.13.1 lib/redmine_plugins_helper/settings.rb
redmine_plugins_helper-0.13.0 lib/redmine_plugins_helper/settings.rb
redmine_plugins_helper-0.12.2 lib/redmine_plugins_helper/settings.rb
redmine_plugins_helper-0.12.1 lib/redmine_plugins_helper/settings.rb
redmine_plugins_helper-0.12.0 lib/redmine_plugins_helper/settings.rb
redmine_plugins_helper-0.11.0 lib/redmine_plugins_helper/settings.rb
redmine_plugins_helper-0.10.0 lib/redmine_plugins_helper/settings.rb