Class: Aquarium::Utils::NilObject

Inherits:
Object
  • Object
show all
Defined in:
lib/aquarium/utils/nil_object.rb

Overview

An implementation of the Null Object Pattern (renamed “Nil” for Ruby). All methods not defined by Object simply return the Aquarium::Utils::NilObject itself. Users can subclass or add methods to instances to customize the behavior.

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_sym, *args) ⇒ Object



13
14
15
# File 'lib/aquarium/utils/nil_object.rb', line 13

def method_missing method_sym, *args
  self
end

Instance Method Details

#eql?(other) ⇒ Boolean

Returns:

  • (Boolean)


9
10
11
# File 'lib/aquarium/utils/nil_object.rb', line 9

def eql? other
  other.kind_of? NilObject
end