Sha256: fe7844332d3e0b5bea610a4323c5f56aeab46114aea7dcb58933d52a32d91c54

Contents?: true

Size: 1.1 KB

Versions: 22

Compression:

Stored size: 1.1 KB

Contents

# frozen_string_literal: true

require_relative '../../models/color_theme'

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

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

          @project_hash = project_hash
          @options = options || {}
        end

        def call
          Models::Project.new(**hydrate)
        end

        private

        attr_reader :project_hash, :options

        # Not much going on here at all, but it's here for consistency.
        # Perform any pre-processing of the project_hash here (e.g. symbolize keys,
        # convert values to the correct type, etc.).
        def hydrate
          project_hash
        end
      end
    end
  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

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