Class: ConvenientService::Examples::Standard::V1::Gemfile::Services::MergeSections
- Inherits:
-
Object
- Object
- ConvenientService::Examples::Standard::V1::Gemfile::Services::MergeSections
- Includes:
- Service::Configs::Standard::V1
- Defined in:
- lib/convenient_service/examples/standard/v1/gemfile/services/merge_sections.rb
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#header ⇒ Object
readonly
Returns the value of attribute header.
Instance Method Summary collapse
-
#initialize(header:, body:) ⇒ MergeSections
constructor
A new instance of MergeSections.
- #result ⇒ Object
- #validate_body ⇒ Object
- #validate_header ⇒ Object
Methods included from Config
Constructor Details
#initialize(header:, body:) ⇒ MergeSections
Returns a new instance of MergeSections.
31 32 33 34 |
# File 'lib/convenient_service/examples/standard/v1/gemfile/services/merge_sections.rb', line 31 def initialize(header:, body:) @header = header @body = body end |
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body.
17 18 19 |
# File 'lib/convenient_service/examples/standard/v1/gemfile/services/merge_sections.rb', line 17 def body @body end |
#header ⇒ Object (readonly)
Returns the value of attribute header.
17 18 19 |
# File 'lib/convenient_service/examples/standard/v1/gemfile/services/merge_sections.rb', line 17 def header @header end |
Instance Method Details
#result ⇒ Object
36 37 38 |
# File 'lib/convenient_service/examples/standard/v1/gemfile/services/merge_sections.rb', line 36 def result success(merged_sections: "#{header}\n#{body}") end |
#validate_body ⇒ Object
47 48 49 50 51 52 |
# File 'lib/convenient_service/examples/standard/v1/gemfile/services/merge_sections.rb', line 47 def validate_body return failure(body: "Body is `nil`") if body.nil? return failure(body: "Body is empty") if body.empty? success end |
#validate_header ⇒ Object
40 41 42 43 44 45 |
# File 'lib/convenient_service/examples/standard/v1/gemfile/services/merge_sections.rb', line 40 def validate_header return failure(header: "Header is `nil`") if header.nil? return failure(header: "Header is empty") if header.empty? success end |