Sha256: 772866346c3d8f3de9b1f47723e6439226cf491c6317d3e90d76733ed5fff39e

Contents?: true

Size: 1.01 KB

Versions: 48

Compression:

Stored size: 1.01 KB

Contents

# frozen_string_literal: true

require_relative '../../models/entry_group'
require_relative '../entry/hydrator_service'

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

          @entry_group_hash = entry_group_hash
          @options = options || {}
        end

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

        private

        attr_reader :entry_group_hash, :options

        # Returns a Hash with :time and :entries values hydrated (i.e. Time and Entry objects respectively).
        def hydrate
          entry_group_hash.tap do |hash|
            hash[:time] = Time.parse(hash[:time])
            hash[:entries] =
              Entry::HydratorService.new(entries_array: hash[:entries], options: options).call
          end
        end
      end
    end
  end
end

Version data entries

48 entries across 48 versions & 1 rubygems

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