Class: ChainableSafeNil

Inherits:
BasicObject
Includes:
Singleton
Defined in:
lib/quality_extensions/chainable_safe_nil.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



69
70
71
72
73
# File 'lib/quality_extensions/chainable_safe_nil.rb', line 69

def method_missing(method, *args, &block)
  #puts "nil.respond_to?(method)=#{nil.respond_to?(method)}"
  return ChainableSafeNil.instance  unless nil.respond_to?(method)
  nil.send(method, *args, &block) rescue ChainableSafeNil.instance
end

Instance Method Details

#==(other) ⇒ Object



75
76
77
78
# File 'lib/quality_extensions/chainable_safe_nil.rb', line 75

def ==(other)
  #other.nil?
  raise "Why on earth is this line never getting executed?? And yet if I remove this method entirely, equality breaks"
end

#inspectObject



65
66
67
# File 'lib/quality_extensions/chainable_safe_nil.rb', line 65

def inspect
  "ChainableSafeNil"
end

#nil?Boolean

Returns:

  • (Boolean)


80
# File 'lib/quality_extensions/chainable_safe_nil.rb', line 80

def nil?; true; end