Sha256: a3db11fbf48b583137a0ba98000a5e37c78c5a21fc8dddc746519156246aa09c

Contents?: true

Size: 1.05 KB

Versions: 5

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

module ConvenientService
  module Examples
    module Standard
      class RequestParams
        module Services
          class CastParams
            include ConvenientService::Standard::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

Version data entries

5 entries across 5 versions & 1 rubygems

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