Module: Contracts::Eigenclass

Defined in:
lib/contracts/eigenclass.rb

Defined Under Namespace

Modules: NullEigenclass

Class Method Summary collapse

Class Method Details

.extended(eigenclass) ⇒ Object


3
4
5
6
7
8
9
# File 'lib/contracts/eigenclass.rb', line 3

def self.extended(eigenclass)
  return if eigenclass.respond_to?(:owner_class=)

  class << eigenclass
    attr_accessor :owner_class
  end
end

.lift(base) ⇒ Object


11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/contracts/eigenclass.rb', line 11

def self.lift(base)
  return NullEigenclass if Support.eigenclass? base

  eigenclass = Support.eigenclass_of base

  eigenclass.extend(Eigenclass) unless eigenclass.respond_to?(:owner_class=)

  unless eigenclass.respond_to?(:pop_decorators)
    eigenclass.extend(MethodDecorators)
    eigenclass.send(:include, Contracts)
  end

  eigenclass.owner_class = base

  eigenclass
end