Module: Contracts::Invariants

Defined in:
lib/contracts/invariants.rb

Defined Under Namespace

Modules: InvariantExtension Classes: Invariant

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.common(base) ⇒ Object



11
12
13
14
15
# File 'lib/contracts/invariants.rb', line 11

def self.common(base)
  return if base.respond_to?(:Invariant)

  base.extend(InvariantExtension)
end

.extended(base) ⇒ Object



7
8
9
# File 'lib/contracts/invariants.rb', line 7

def self.extended(base)
  common base
end

.included(base) ⇒ Object



3
4
5
# File 'lib/contracts/invariants.rb', line 3

def self.included(base)
  common base
end

Instance Method Details

#verify_invariants!(method) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/contracts/invariants.rb', line 17

def verify_invariants!(method)
  return unless self.class.respond_to?(:invariants)

  self.class.invariants.each do |invariant|
    invariant.check_on(self, method)
  end
end