Class: ConvenientService::Support::UniqueValue

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(label = default_label) ⇒ void

Parameters:

  • label (String) (defaults to: default_label)


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

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

Instance Attribute Details

#labelObject (readonly)

Returns the value of attribute label.



10
11
12
# File 'lib/convenient_service/support/unique_value.rb', line 10

def label
  @label
end

Instance Method Details

#==(other) ⇒ Boolean

Parameters:

  • other (Object)

    Can be any type.

Returns:

  • (Boolean)


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

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

  object_id == other.object_id
end

#===(other) ⇒ Boolean

Parameters:

  • other (Object)

    Can be any type.

Returns:

  • (Boolean)


37
38
39
# File 'lib/convenient_service/support/unique_value.rb', line 37

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

#eql?(other) ⇒ Boolean

Parameters:

  • other (Object)

    Can be any type.

Returns:

  • (Boolean)


48
49
50
# File 'lib/convenient_service/support/unique_value.rb', line 48

def eql?(other)
  self == other
end

#inspectString

Returns:

  • (String)


55
56
57
58
59
60
# File 'lib/convenient_service/support/unique_value.rb', line 55

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

  label
end