Sha256: 88017101d1d93fde66ea46342864e79b9fd2ead191bf55e25e55453f6cc204af

Contents?: true

Size: 1.16 KB

Versions: 48

Compression:

Stored size: 1.16 KB

Contents

# frozen_string_literal: true

require_relative '../../models/configuration'
require_relative '../../views/shared/message'

module Dsu
  module Services
    module Configuration
      class HydratorService
        def initialize(config_hash:, options: {})
          raise ArgumentError, 'config_hash is nil' if config_hash.nil?

          unless config_hash.is_a?(Hash)
            raise ArgumentError,
              "config_hash is the wrong object type: \"#{config_hash}\""
          end
          raise ArgumentError, 'options is nil' if options.nil?
          raise ArgumentError, "options is the wrong object type:\"#{options}\"" unless options.is_a?(Hash)

          @config_hash = config_hash.dup
          @options = options || {}
        end

        def call
          hydrate
        end

        private

        attr_reader :config_hash, :options

        def hydrate
          config_hash[:version] = config_hash[:version].to_i
          config_hash[:entries_display_order] = config_hash[:entries_display_order].to_sym
          config_hash
        rescue JSON::ParserError => _e
          Models::Configuration::DEFAULT_CONFIGURATION
        end
      end
    end
  end
end

Version data entries

48 entries across 48 versions & 1 rubygems

Version Path
dsu-3.0.5 lib/dsu/services/configuration/hydrator_service.rb
dsu-3.0.4 lib/dsu/services/configuration/hydrator_service.rb
dsu-3.0.3 lib/dsu/services/configuration/hydrator_service.rb
dsu-3.0.1 lib/dsu/services/configuration/hydrator_service.rb
dsu-3.0.0 lib/dsu/services/configuration/hydrator_service.rb
dsu-3.0.0.beta.3 lib/dsu/services/configuration/hydrator_service.rb
dsu-3.0.0.beta.2 lib/dsu/services/configuration/hydrator_service.rb
dsu-3.0.0.beta.1 lib/dsu/services/configuration/hydrator_service.rb
dsu-3.0.0.beta.0 lib/dsu/services/configuration/hydrator_service.rb
dsu-3.0.0.alpha.12 lib/dsu/services/configuration/hydrator_service.rb
dsu-3.0.0.alpha.11 lib/dsu/services/configuration/hydrator_service.rb
dsu-3.0.0.alpha.10 lib/dsu/services/configuration/hydrator_service.rb
dsu-3.0.0.alpha.9 lib/dsu/services/configuration/hydrator_service.rb
dsu-3.0.0.alpha.8 lib/dsu/services/configuration/hydrator_service.rb
dsu-3.0.0.alpha.7 lib/dsu/services/configuration/hydrator_service.rb
dsu-3.0.0.alpha.6 lib/dsu/services/configuration/hydrator_service.rb
dsu-3.0.0.alpha.5 lib/dsu/services/configuration/hydrator_service.rb
dsu-3.0.0.alpha.4 lib/dsu/services/configuration/hydrator_service.rb
dsu-3.0.0.alpha.3 lib/dsu/services/configuration/hydrator_service.rb
dsu-3.0.0.alpha.2 lib/dsu/services/configuration/hydrator_service.rb