Class: Mongory::Utils::SingletonBuilder
- Inherits:
-
Object
- Object
- Mongory::Utils::SingletonBuilder
- Defined in:
- lib/mongory/utils/singleton_builder.rb
Overview
A singleton placeholder object used to represent special sentinel values.
Used in situations where nil
is a valid value and cannot be used as a marker.
Typically used for internal constants like NOTHING
or KEY_NOT_FOUND
.
Direct Known Subclasses
Instance Method Summary collapse
-
#initialize(label, &block) ⇒ SingletonBuilder
constructor
A new instance of SingletonBuilder.
-
#inspect ⇒ String
Formatted label.
-
#to_s ⇒ String
Formatted label.
Constructor Details
#initialize(label, &block) ⇒ SingletonBuilder
Returns a new instance of SingletonBuilder.
15 16 17 18 |
# File 'lib/mongory/utils/singleton_builder.rb', line 15 def initialize(label, &block) @label = label instance_eval(&block) if block_given? end |
Instance Method Details
#inspect ⇒ String
Returns formatted label.
21 22 23 |
# File 'lib/mongory/utils/singleton_builder.rb', line 21 def inspect "#<#{@label}>" end |
#to_s ⇒ String
Returns formatted label.
26 27 28 |
# File 'lib/mongory/utils/singleton_builder.rb', line 26 def to_s "#<#{@label}>" end |