Class: ConvenientService::Support::UniqueValue Private

Inherits:
Object
  • Object
show all
Defined in:
lib/convenient_service/support/unique_value.rb

Overview

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Since:

  • 1.0.0

Direct Known Subclasses

Block, NotPassed, Undefined

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(label = default_label) ⇒ void

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • label (String) (defaults to: default_label)

Since:

  • 1.0.0



21
22
23
# File 'lib/convenient_service/support/unique_value.rb', line 21

def initialize(label = default_label)
  @label = label
end

Instance Attribute Details

#labelObject (readonly)

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Since:

  • 1.0.0



15
16
17
# File 'lib/convenient_service/support/unique_value.rb', line 15

def label
  @label
end

Instance Method Details

#==(other) ⇒ Boolean?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • other (Object)

    Can be any type.

Returns:

  • (Boolean, nil)

Since:

  • 1.0.0



41
42
43
44
45
# File 'lib/convenient_service/support/unique_value.rb', line 41

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

  equal?(other)
end

#===(other) ⇒ Boolean?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • other (Object)

    Can be any type.

Returns:

  • (Boolean, nil)

Since:

  • 1.0.0



51
52
53
# File 'lib/convenient_service/support/unique_value.rb', line 51

def ===(other)
  self == other
end

#[](value) ⇒ Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • value (Object)

    Can be any type.

Returns:

  • (Boolean)

Since:

  • 1.0.0



29
30
31
# File 'lib/convenient_service/support/unique_value.rb', line 29

def [](value)
  equal?(value)
end

#eql?(other) ⇒ Boolean?

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

  • other (Object)

    Can be any type.

Returns:

  • (Boolean, nil)

Since:

  • 1.0.0



68
69
70
71
72
# File 'lib/convenient_service/support/unique_value.rb', line 68

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

  equal?(other)
end

#hashInteger

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Integer)

Since:

  • 1.0.0



81
82
83
# File 'lib/convenient_service/support/unique_value.rb', line 81

def hash
  [self.class, label].hash
end

#inspectString

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (String)

Since:

  • 1.0.0



88
89
90
91
92
93
# File 'lib/convenient_service/support/unique_value.rb', line 88

def inspect
  return default_label if label.nil?
  return default_label if label.empty?

  label
end