Class: DBC

Inherits:
Object show all
Defined in:
lib/tworgy/dbc.rb

Defined Under Namespace

Classes: AssertconditionException, FailException, PostconditionException, PreconditionException

Class Method Summary collapse

Class Method Details

.assert(condition, message = "") ⇒ Object



19
20
21
22
23
# File 'lib/tworgy/dbc.rb', line 19

def self.assert(condition, message = "")
  unless condition
    error(AssertconditionException, message, caller)
  end
end

.ensure(condition, message = "") ⇒ Object



25
26
27
28
29
# File 'lib/tworgy/dbc.rb', line 25

def self.ensure(condition, message = "")
  unless condition
    error(PostconditionException, message, caller)
  end
end

.fail(message = "") ⇒ Object



31
32
33
# File 'lib/tworgy/dbc.rb', line 31

def self.fail(message = "")
  error(FailException, message, caller)
end

.require(condition, message = "") ⇒ Object



7
8
9
10
11
# File 'lib/tworgy/dbc.rb', line 7

def self.require(condition, message = "")
  unless condition
    error(PreconditionException, message, caller)
  end
end

.require_not_blank(string, message = "") ⇒ Object



13
14
15
16
17
# File 'lib/tworgy/dbc.rb', line 13

def self.require_not_blank(string, message = "")
  if string.nil? || string.strip.blank?
    error(PreconditionException, message, caller)
  end
end