Sha256: d1180a970b0293f8f129d62451720244f96ddadef2af4575f04d3fc3d3483264

Contents?: true

Size: 743 Bytes

Versions: 10

Compression:

Stored size: 743 Bytes

Contents

# frozen_string_literal: true

require_relative 'method_decorator'
require_relative 'engine'
require_relative 'engine_proxy'

module Ree::Contracts
  module Contractable
    if !Ree::Contracts.no_contracts?
      def method_added(name)
        MethodDecorator.new(name, false, self).call
        super
      end

      def singleton_method_added(name)
        MethodDecorator.new(name, true, self).call
        super
      end
    end

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

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

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ree-1.0.9 lib/ree/contracts/contractable.rb
ree-1.0.8 lib/ree/contracts/contractable.rb
ree-1.0.7 lib/ree/contracts/contractable.rb
ree-1.0.6 lib/ree/contracts/contractable.rb
ree-1.0.5 lib/ree/contracts/contractable.rb
ree-1.0.4 lib/ree/contracts/contractable.rb
ree-1.0.3 lib/ree/contracts/contractable.rb
ree-1.0.2 lib/ree/contracts/contractable.rb
ree-1.0.1 lib/ree/contracts/contractable.rb
ree-1.0.0 lib/ree/contracts/contractable.rb