Sha256: 6fa1c2187d3a2928f8ea6e03af45168b67e2394bd79016f02c37bb68905b330f

Contents?: true

Size: 677 Bytes

Versions: 2

Compression:

Stored size: 677 Bytes

Contents

# frozen_string_literal: true

module ConvenientService
  module Examples
    module Dry
      module Gemfile
        module Services
          class ReadFileContent
            include DryService::Config

            option :path

            contract do
              schema do
                required(:path).value(:string)
              end
            end

            step Services::AssertFileExists, in: :path
            step Services::AssertFileNotEmpty, in: :path
            step :result, in: :path, out: :content

            def result
              success(data: {content: ::File.read(path)})
            end
          end
        end
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
convenient_service-0.2.0 lib/convenient_service/examples/dry/gemfile/services/read_file_content.rb
convenient_service-0.1.0 lib/convenient_service/examples/dry/gemfile/services/read_file_content.rb