Sha256: 889be3aeffaff3f103489de9e55924bd79e504847162e71cf0c2aa934963b922

Contents?: true

Size: 1.13 KB

Versions: 4

Compression:

Stored size: 1.13 KB

Contents

# frozen_string_literal: true

module ConvenientService
  module Examples
    module Standard
      module V1
        class RequestParams
          module Services
            class CastParams
              include ConvenientService::Standard::V1::Config

              attr_reader :params

              def initialize(params:)
                @params = params
              end

              def result
                success(original_params: params, casted_params: casted_params)
              end

              private

              def casted_params
                {
                  id: Entities::ID.cast(params[:id]),
                  format: Entities::Format.cast(params[:format]),
                  title: Entities::Title.cast(params[:title]),
                  description: Entities::Description.cast(params[:description]),
                  tags: Utils::Array.wrap(params[:tags]).map { |tag| Entities::Tag.cast(tag) },
                  sources: Utils::Array.wrap(params[:sources]).map { |source| Entities::Source.cast(source) }
                }
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
convenient_service-0.17.0 lib/convenient_service/examples/standard/v1/request_params/services/cast_params.rb
convenient_service-0.16.0 lib/convenient_service/examples/standard/v1/request_params/services/cast_params.rb
convenient_service-0.15.0 lib/convenient_service/examples/standard/v1/request_params/services/cast_params.rb
convenient_service-0.14.0 lib/convenient_service/examples/standard/v1/request_params/services/cast_params.rb