Class: RSpecial::Operatics

Inherits:
Object
  • Object
show all
Defined in:
lib/rspecial/operatics.rb

Overview

Operatics delegates operator based assertions for execpt.rb.

Instance Method Summary collapse

Constructor Details

#initialize(target, negate = false) ⇒ Operatics

Returns a new instance of Operatics.



9
10
11
12
# File 'lib/rspecial/operatics.rb', line 9

def initialize(target, negate=false)
  @target = target
  @negate = negate
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(op, *a, &b) ⇒ Object (private)



17
18
19
20
21
22
23
24
25
# File 'lib/rspecial/operatics.rb', line 17

def method_missing(op, *a, &b)
  super(op, *a, &b) if op.to_s =~ /^\w/

  if @negate
    refute!(op, *a, &b)
  else
    assert!(op, *a, &b)
  end
end