Module: Ree::Contracts::Contractable

Defined in:
lib/ree/contracts/contractable.rb

Instance Method Summary collapse

Instance Method Details

#contract(*args, &block) ⇒ Object



28
29
30
31
32
# File 'lib/ree/contracts/contractable.rb', line 28

def contract(*args, &block)
  engine = Engine.fetch_for(self)
  engine.add_contract(*args, &block)
  EngineProxy.new(engine)
end

#doc(str) ⇒ Object



21
22
23
24
25
26
# File 'lib/ree/contracts/contractable.rb', line 21

def doc(str)
  return if Ree::Contracts.no_contracts?
  
  engine = Engine.fetch_for(self)
  engine.add_doc(str.strip)
end

#method_added(name) ⇒ Object



9
10
11
12
13
# File 'lib/ree/contracts/contractable.rb', line 9

def method_added(name)
  return super if _ree_method_added_hook_active?
  MethodDecorator.new(name, false, self).call(plugin_mode: false)
  super
end

#singleton_method_added(name) ⇒ Object



15
16
17
18
19
# File 'lib/ree/contracts/contractable.rb', line 15

def singleton_method_added(name)
  return super if _ree_method_added_hook_active?
  MethodDecorator.new(name, true, self).call(plugin_mode: false)
  super
end