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


13
14
15
16
17
# File 'lib/contracts/invariants.rb', line 13

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

  base.extend(InvariantExtension)
end

.extended(base) ⇒ Object


9
10
11
# File 'lib/contracts/invariants.rb', line 9

def self.extended(base)
  common base
end

.included(base) ⇒ Object


5
6
7
# File 'lib/contracts/invariants.rb', line 5

def self.included(base)
  common base
end

Instance Method Details

#verify_invariants!(method) ⇒ Object


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

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

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