Module: Naught::Conversions

### Home Classes Methods

### In Files

- lib/naught/conversions.rb

### Methods

- ::included
- #Actual
- #Just
- #Maybe
- #Null

### Class/Module Index

Quicksearch

- Naught
- Naught::Conversions
- Naught::NullClassBuilder
- Naught::NullClassBuilder::Command
- Naught::NullClassBuilder::Commands
- Naught::NullClassBuilder::Commands::DefineExplicitConversions
- Naught::NullClassBuilder::Commands::DefineImplicitConversions
- Naught::NullClassBuilder::Commands::Impersonate
- Naught::NullClassBuilder::Commands::Mimic
- Naught::NullClassBuilder::Commands::Pebble
- Naught::NullClassBuilder::Commands::PredicatesReturn
- Naught::NullClassBuilder::Commands::Singleton
- Naught::NullClassBuilder::Commands::Traceable
- Naught::NullObjectTag

No matching classes.

# Naught::Conversions

### Public Class Methods

included(null_class) click to toggle source

    # File lib/naught/conversions.rb, line 3
    def self.included(null_class)
      unless class_variable_defined?(:@@included) && @@included
        @@null_class = null_class
        @@null_equivs = null_class::NULL_EQUIVS
        @@included = true
      end
      super
    end

### Public Instance Methods

Actual(object = nil) click to toggle source

    # File lib/naught/conversions.rb, line 45
    def Actual(object = nil)
      object = yield if block_given?
      case object
      when NullObjectTag
        nil
      else
        object
      end
    end

Just(object = nil) click to toggle source

    # File lib/naught/conversions.rb, line 35
    def Just(object = nil)
      object = yield if block_given?
      case object
      when NullObjectTag, *@@null_equivs
        fail ArgumentError, "Null value: #{object.inspect}"
      else
        object
      end
    end

Maybe(object = nil) click to toggle source

    # File lib/naught/conversions.rb, line 23
    def Maybe(object = nil)
      object = yield if block_given?
      case object
      when NullObjectTag
        object
      when *@@null_equivs
        @@null_class.get(:caller => caller(1))
      else
        object
      end
    end

Null(object = :nothing_passed) click to toggle source

    # File lib/naught/conversions.rb, line 12
    def Null(object = :nothing_passed)
      case object
      when NullObjectTag
        object
      when :nothing_passed, *@@null_equivs
        @@null_class.get(:caller => caller(1))
      else
        fail ArgumentError, "#{object.inspect} is not null!"
      end
    end

[Validate]

Generated with the Darkfish Rdoc Generator 2.