Sha256: d21d403d5f34687a118d6aae54db90430c2d41682f2efcf1ec911781bed9b092

Contents?: true

Size: 1.12 KB

Versions: 4

Compression:

Stored size: 1.12 KB

Contents

# frozen_string_literal: true

module ConvenientService
  module Examples
    module Standard
      class Gemfile
        module Services
          class MergeSections
            include ConvenientService::Standard::Config

            attr_reader :header, :body

            step :validate_header,
              in: :header

            step :validate_body,
              in: :body

            step :result,
              in: [
                :header,
                :body
              ]

            def initialize(header:, body:)
              @header = header
              @body = body
            end

            def result
              success(merged_sections: "#{header}\n#{body}")
            end

            def validate_header
              return error("Header is `nil`") if header.nil?
              return error("Header is empty") if header.empty?

              success
            end

            def validate_body
              return error("Body is `nil`") if body.nil?
              return error("Body is empty") if body.empty?

              success
            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/gemfile/services/merge_sections.rb
convenient_service-0.16.0 lib/convenient_service/examples/standard/gemfile/services/merge_sections.rb
convenient_service-0.15.0 lib/convenient_service/examples/standard/gemfile/services/merge_sections.rb
convenient_service-0.14.0 lib/convenient_service/examples/standard/gemfile/services/merge_sections.rb