Sha256: 3fbcc4ceceb59b1ded5b365d93756f395626f0ef33435ae5fdc26c2b3f6b1394

Contents?: true

Size: 842 Bytes

Versions: 28

Compression:

Stored size: 842 Bytes

Contents

module Workarea
  module Admin
    module SettingsHelper
      def sanitize_config_value(value)
        return if value.blank? && value.to_s != 'false'

        case value
        when ActiveSupport::Duration
          amount, unit = value.parts.first.reverse
          duration = pluralize(amount, unit.to_s.singularize)
          tag.code html_escape(duration), class: 'code code--block'
        when SwappableList
          tag.pre data: { expandable: '' } do
            tag.code JSON.pretty_generate(value.to_a), class: 'code code--block'
          end
        when Hash, Array
          tag.pre data: { expandable: '' } do
            tag.code JSON.pretty_generate(value), class: 'code code--block'
          end
        else
          tag.code html_escape(value.to_s), class: 'code code--block'
        end
      end
    end
  end
end

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
workarea-admin-3.5.6 app/helpers/workarea/admin/settings_helper.rb
workarea-admin-3.5.5 app/helpers/workarea/admin/settings_helper.rb
workarea-admin-3.5.4 app/helpers/workarea/admin/settings_helper.rb
workarea-admin-3.5.3 app/helpers/workarea/admin/settings_helper.rb
workarea-admin-3.5.2 app/helpers/workarea/admin/settings_helper.rb
workarea-admin-3.5.1 app/helpers/workarea/admin/settings_helper.rb
workarea-admin-3.5.0 app/helpers/workarea/admin/settings_helper.rb
workarea-admin-3.5.0.beta.1 app/helpers/workarea/admin/settings_helper.rb