Sha256: 576572765a291b228fbe3138c9a0104c5a528ed0412709083c2da788dbf43593

Contents?: true

Size: 473 Bytes

Versions: 4

Compression:

Stored size: 473 Bytes

Contents

module RailsSettings
  module Fields
    class Hash < ::RailsSettings::Fields::Base
      def deserialize(value)
        return nil if value.nil?

        return value unless value.is_a?(::String)

        load_value(value).deep_stringify_keys.with_indifferent_access
      end

      def serialize(value)
        deserialize(value)
      end

      def load_value(value)
        YAML.safe_load(value).to_h
      rescue StandardError
        {}
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rails-settings-cached-2.9.5 lib/rails-settings/fields/hash.rb
rails-settings-cached-2.9.4 lib/rails-settings/fields/hash.rb
rails-settings-cached-2.9.3 lib/rails-settings/fields/hash.rb
rails-settings-cached-2.9.2 lib/rails-settings/fields/hash.rb