Class: NullObject

Inherits:
Object
  • Object
show all
Defined in:
lib/geoengineer/utils/null_object.rb

Overview

NullObject and NullObject.maybe provide the NullObject pattern as defined here

Class Method Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(name, *args, &block) ⇒ Object



7
8
9
# File 'lib/geoengineer/utils/null_object.rb', line 7

def method_missing(name, *args, &block)
  nil
end

Class Method Details

.maybe(value) ⇒ Object



11
12
13
14
15
16
# File 'lib/geoengineer/utils/null_object.rb', line 11

def self.maybe(value)
  case value
  when nil then NullObject.new
  else value
  end
end