Class: ConvenientService::Examples::Standard::V1::Gemfile::Services::MergeSections

Inherits:
Object
  • Object
show all
Includes:
Service::Configs::Standard::V1
Defined in:
lib/convenient_service/examples/standard/v1/gemfile/services/merge_sections.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(header:, body:) ⇒ MergeSections

Returns a new instance of MergeSections.



26
27
28
29
# File 'lib/convenient_service/examples/standard/v1/gemfile/services/merge_sections.rb', line 26

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

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



12
13
14
# File 'lib/convenient_service/examples/standard/v1/gemfile/services/merge_sections.rb', line 12

def body
  @body
end

#headerObject (readonly)

Returns the value of attribute header.



12
13
14
# File 'lib/convenient_service/examples/standard/v1/gemfile/services/merge_sections.rb', line 12

def header
  @header
end

Instance Method Details

#resultObject



31
32
33
# File 'lib/convenient_service/examples/standard/v1/gemfile/services/merge_sections.rb', line 31

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

#validate_bodyObject



42
43
44
45
46
47
# File 'lib/convenient_service/examples/standard/v1/gemfile/services/merge_sections.rb', line 42

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

  success
end

#validate_headerObject



35
36
37
38
39
40
# File 'lib/convenient_service/examples/standard/v1/gemfile/services/merge_sections.rb', line 35

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

  success
end