Class: ConvenientService::Examples::Standard::V1::RequestParams::Entities::ID

Inherits:
Object
  • Object
show all
Defined in:
lib/convenient_service/examples/standard/v1/request_params/entities/id.rb

Overview

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value:) ⇒ ID

Returns a new instance of ID.



13
14
15
# File 'lib/convenient_service/examples/standard/v1/request_params/entities/id.rb', line 13

def initialize(value:)
  @value = value
end

Class Method Details

.cast(value) ⇒ Object



18
19
20
21
22
23
# File 'lib/convenient_service/examples/standard/v1/request_params/entities/id.rb', line 18

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

Instance Method Details

#==(other) ⇒ Object



26
27
28
29
30
# File 'lib/convenient_service/examples/standard/v1/request_params/entities/id.rb', line 26

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

  value == other.value
end

#to_iObject



32
33
34
# File 'lib/convenient_service/examples/standard/v1/request_params/entities/id.rb', line 32

def to_i
  value.to_i
end

#to_sObject



36
37
38
# File 'lib/convenient_service/examples/standard/v1/request_params/entities/id.rb', line 36

def to_s
  value
end