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.


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

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


203
204
205
206
207
208
209
210
# File 'lib/epitools/core_ext/object.rb', line 203

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


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

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

#is_a?(other) ⇒ Boolean

Returns:

  • (Boolean)

199
200
201
# File 'lib/epitools/core_ext/object.rb', line 199

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