module DesignByContract
Public Instance Methods
as_dependency_injection_for(klass, initialize_signature_spec)
click to toggle source
# File lib/design_by_contract.rb, line 19 def as_dependency_injection_for(klass, initialize_signature_spec) register_contract DesignByContract::Pattern::DependencyInjection.new(klass, initialize_signature_spec) end
enable_defensive_contract()
click to toggle source
# File lib/design_by_contract.rb, line 14 def enable_defensive_contract @defensive_contract = true fulfill_contracts! end
forget_contract_specifications!()
click to toggle source
# File lib/design_by_contract.rb, line 8 def forget_contract_specifications! contracts.keys.each(&:down) contracts.clear nil end
Private Instance Methods
contracts()
click to toggle source
# File lib/design_by_contract.rb, line 25 def contracts @__contracts__ ||= {} end
fulfill_contracts!()
click to toggle source
# File lib/design_by_contract.rb, line 34 def fulfill_contracts! contracts.each do |contract, state| next if state == :active contract.up contracts[contract] = :active end end
register_contract(contract)
click to toggle source
# File lib/design_by_contract.rb, line 29 def register_contract(contract) contracts[contract] = :inactive fulfill_contracts! if @defensive_contract end