Sha256: 44181932cb87edbabe27134fc92707eefad177df296063b9cacc29cc3b6dc1e9

Contents?: true

Size: 929 Bytes

Versions: 8

Compression:

Stored size: 929 Bytes

Contents

# frozen_string_literal: true

module ConvenientService
  module Examples
    module Standard
      module 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

8 entries across 8 versions & 1 rubygems

Version Path
convenient_service-0.12.0 lib/convenient_service/examples/standard/request_params/entities/id.rb
convenient_service-0.11.0 lib/convenient_service/examples/standard/request_params/entities/id.rb
convenient_service-0.10.1 lib/convenient_service/examples/standard/request_params/entities/id.rb
convenient_service-0.10.0 lib/convenient_service/examples/standard/request_params/entities/id.rb
convenient_service-0.9.0 lib/convenient_service/examples/standard/request_params/entities/id.rb
convenient_service-0.8.0 lib/convenient_service/examples/standard/request_params/entities/id.rb
convenient_service-0.7.0 lib/convenient_service/examples/standard/request_params/entities/id.rb
convenient_service-0.6.0 lib/convenient_service/examples/standard/request_params/entities/id.rb