Sha256: 24c3fd284219846296eefb54716b53ad1615610dd55b6b1c937e3ba02bfc3e54

Contents?: true

Size: 1.05 KB

Versions: 8

Compression:

Stored size: 1.05 KB

Contents

# frozen_string_literal: true

module ConvenientService
  module Examples
    module Standard
      module 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

8 entries across 8 versions & 1 rubygems

Version Path
convenient_service-0.12.0 lib/convenient_service/examples/standard/request_params/services/cast_params.rb
convenient_service-0.11.0 lib/convenient_service/examples/standard/request_params/services/cast_params.rb
convenient_service-0.10.1 lib/convenient_service/examples/standard/request_params/services/cast_params.rb
convenient_service-0.10.0 lib/convenient_service/examples/standard/request_params/services/cast_params.rb
convenient_service-0.9.0 lib/convenient_service/examples/standard/request_params/services/cast_params.rb
convenient_service-0.8.0 lib/convenient_service/examples/standard/request_params/services/cast_params.rb
convenient_service-0.7.0 lib/convenient_service/examples/standard/request_params/services/cast_params.rb
convenient_service-0.6.0 lib/convenient_service/examples/standard/request_params/services/cast_params.rb