Class: Naught::NullClassBuilder::Commands::DefineExplicitConversions Private
- Inherits:
-
Naught::NullClassBuilder::Command
- Object
- Naught::NullClassBuilder::Command
- Naught::NullClassBuilder::Commands::DefineExplicitConversions
- Defined in:
- lib/naught/null_class_builder/commands/define_explicit_conversions.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.
Adds explicit conversion methods delegating to nil
These methods return the same values that nil returns:
- to_a => []
- to_c => (0+0i)
- to_f => 0.0
- to_h => {}
- to_i => 0
- to_r => (0/1)
- to_s => ""
Instance Attribute Summary
Attributes inherited from Naught::NullClassBuilder::Command
Instance Method Summary collapse
-
#call ⇒ void
private
Install explicit conversion methods.
Methods inherited from Naught::NullClassBuilder::Command
Constructor Details
This class inherits a constructor from Naught::NullClassBuilder::Command
Instance Method Details
#call ⇒ 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.
This method returns an undefined value.
Install explicit conversion methods
25 26 27 |
# File 'lib/naught/null_class_builder/commands/define_explicit_conversions.rb', line 25 def call defer { |subject| METHODS.each { |name| subject.define_method(name) { nil.public_send(name) } } } end |