Sha256: 05ca1c200e92eba83f0f7caaad2c3b393fea68b818e65ec426d5fa6f4ab30c92

Contents?: true

Size: 1.62 KB

Versions: 4

Compression:

Stored size: 1.62 KB

Contents

# frozen_string_literal: true

require_relative "status/class_methods"

module ConvenientService
  module Service
    module Plugins
      module HasResult
        module Entities
          class Result
            module Plugins
              module HasJsendStatusAndAttributes
                module Entities
                  class Status
                    include Support::Castable

                    extend ClassMethods

                    attr_reader :value

                    def initialize(value:)
                      @value = value
                    end

                    def ==(other)
                      casted = cast(other)

                      return unless casted

                      value == casted.value
                    end

                    def success?
                      value == :success
                    end

                    def failure?
                      value == :failure
                    end

                    def error?
                      value == :error
                    end

                    def not_success?
                      !success?
                    end

                    def not_failure?
                      !failure?
                    end

                    def not_error?
                      !error?
                    end

                    def to_s
                      @to_s ||= value.to_s
                    end

                    def to_sym
                      @to_sym ||= value.to_sym
                    end
                  end
                end
              end
            end
          end
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
convenient_service-0.3.1 lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/status.rb
convenient_service-0.3.0 lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/status.rb
convenient_service-0.2.1 lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/status.rb
convenient_service-0.2.0 lib/convenient_service/service/plugins/has_result/entities/result/plugins/has_jsend_status_and_attributes/entities/status.rb