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

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Service::Configs::Standard

service?, service_class?

Methods included from Config

included

Constructor Details

#initialize(header:, body:) ⇒ MergeSections

Returns a new instance of MergeSections.



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

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

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



16
17
18
# File 'lib/convenient_service/examples/standard/gemfile/services/merge_sections.rb', line 16

def body
  @body
end

#headerObject (readonly)

Returns the value of attribute header.



16
17
18
# File 'lib/convenient_service/examples/standard/gemfile/services/merge_sections.rb', line 16

def header
  @header
end

Instance Method Details

#resultObject



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

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

#validate_bodyObject



46
47
48
49
50
51
# File 'lib/convenient_service/examples/standard/gemfile/services/merge_sections.rb', line 46

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

  success
end

#validate_headerObject



39
40
41
42
43
44
# File 'lib/convenient_service/examples/standard/gemfile/services/merge_sections.rb', line 39

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

  success
end