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



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

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



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

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



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

def inspect
  "ChainableSafeNil"
end

#nil?Boolean

Returns:

  • (Boolean)


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

def nil?; true; end