Class: NotWrapper

Inherits:
BasicObject
Defined in:
lib/epitools/core_ext/object.rb

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(orig) ⇒ NotWrapper

Returns a new instance of NotWrapper.



187
188
189
# File 'lib/epitools/core_ext/object.rb', line 187

def initialize(orig)
  @orig = orig
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

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



199
200
201
202
203
204
205
206
# File 'lib/epitools/core_ext/object.rb', line 199

def method_missing(meth, *args, &block)
  result = @orig.send(meth, *args, &block)
  if result.is_a? ::TrueClass or result.is_a? ::FalseClass
    !result
  else
    raise "Sorry, I don't know how to invert #{result.inspect}"
  end
end

Instance Method Details

#inspectObject



191
192
193
# File 'lib/epitools/core_ext/object.rb', line 191

def inspect
  "{NOT #{@orig.inspect}}"
end

#is_a?(other) ⇒ Boolean

Returns:

  • (Boolean)


195
196
197
# File 'lib/epitools/core_ext/object.rb', line 195

def is_a?(other)
  other === self
end