Sha256: 61ec41dce0f8da4c41c1b00c955f519b052e7f091a5c05689d3f65c697b7710d

Contents?: true

Size: 439 Bytes

Versions: 2

Compression:

Stored size: 439 Bytes

Contents

module RailsSettings
  module Fields
    class Hash < ::RailsSettings::Fields::Base
      def deserialize(value)
        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

2 entries across 2 versions & 1 rubygems

Version Path
rails-settings-cached-2.9.1 lib/rails-settings/fields/hash.rb
rails-settings-cached-2.9.0 lib/rails-settings/fields/hash.rb