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

Inherits:
Object
  • Object
show all
Defined in:
lib/convenient_service/examples/standard/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.



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

def initialize(value:)
  @value = value
end

Class Method Details

.cast(value) ⇒ Object



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

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

Instance Method Details

#==(other) ⇒ Object



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

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

  value == other.value
end

#to_iObject



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

def to_i
  value.to_i
end

#to_sObject



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

def to_s
  value
end