Class: NotWrapper

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

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(orig) ⇒ NotWrapper


184
185
186
# File 'lib/epitools/core_ext/object.rb', line 184

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


196
197
198
199
200
201
202
203
# File 'lib/epitools/core_ext/object.rb', line 196

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


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

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

#is_a?(other) ⇒ Boolean


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

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