Sha256: 93a2d02d36408f0a7013d7073fd55a77fe9f25d5b46a9617ef61611e127a1b09

Contents?: true

Size: 928 Bytes

Versions: 5

Compression:

Stored size: 928 Bytes

Contents

# frozen_string_literal: true

module ConvenientService
  module Examples
    module Standard
      class RequestParams
        module Entities
          ##
          # TODO: https://ruby-doc.org/3.1.3/stdlibs/yaml/YAML/DBM.html
          #
          class ID
            def initialize(value:)
              @value = value
            end

            class << self
              def cast(value)
                case value
                when ::String, ::Integer
                  new(value: value.to_s)
                end
              end
            end

            def ==(other)
              return unless other.instance_of?(self.class)

              value == other.value
            end

            def to_i
              value.to_i
            end

            def to_s
              value
            end

            protected

            attr_reader :value
          end
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
convenient_service-0.17.0 lib/convenient_service/examples/standard/request_params/entities/id.rb
convenient_service-0.16.0 lib/convenient_service/examples/standard/request_params/entities/id.rb
convenient_service-0.15.0 lib/convenient_service/examples/standard/request_params/entities/id.rb
convenient_service-0.14.0 lib/convenient_service/examples/standard/request_params/entities/id.rb
convenient_service-0.13.0 lib/convenient_service/examples/standard/request_params/entities/id.rb