Module: SmqlToAR::Assertion

Instance Method Summary collapse

Instance Method Details

#raise_if(cond, exception = nil, *args) ⇒ Object

Raises:

  • (exception || Exception)


24
25
26
27
# File 'lib/smql_to_ar.rb', line 24

def raise_if cond, exception = nil, *args
	cond, exception, *args = yield. cond, exception, *args  if block_given?
	raise exception || Exception, *args  if cond
end

#raise_unless(cond, exception = nil, *args) ⇒ Object

Raises:

  • (exception || Exception)


19
20
21
22
# File 'lib/smql_to_ar.rb', line 19

def raise_unless cond, exception = nil, *args
	cond, exception, *args = yield. cond, exception, *args  if block_given?
	raise exception || Exception, *args  unless cond
end