Class: CleanArchitecture::Serializers::HtmlResponseFromResult
- Inherits:
-
Object
- Object
- CleanArchitecture::Serializers::HtmlResponseFromResult
- Defined in:
- lib/clean_architecture/serializers/html_response_from_result.rb
Instance Method Summary collapse
-
#initialize(result, http_method) ⇒ HtmlResponseFromResult
constructor
A new instance of HtmlResponseFromResult.
- #to_h ⇒ Object
Constructor Details
#initialize(result, http_method) ⇒ HtmlResponseFromResult
Returns a new instance of HtmlResponseFromResult.
9 10 11 12 |
# File 'lib/clean_architecture/serializers/html_response_from_result.rb', line 9 def initialize(result, http_method) @result = result @http_method = http_method end |
Instance Method Details
#to_h ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/clean_architecture/serializers/html_response_from_result.rb', line 14 def to_h Dry::Matcher::ResultMatcher.call(@result) do |matcher| matcher.success do |data| { status: Queries::HttpSuccessCode.new(@http_method).to_sym, data: data } end matcher.failure { || { status: :error, error: } } end end |