Module: Nanoc::Int::ContractsSupport Private
- Included in:
- Nanoc::Identifier, CodeSnippet, Configuration, Content, Document, IdentifiableCollection, ItemRep, LazyValue, Pattern, RuleMemory, Site, SnapshotDef
- Defined in:
- lib/nanoc/base/contracts_support.rb
This module is part of a private API. You should avoid using this module if possible, as it may be removed or be changed in the future.
Defined Under Namespace
Modules: DisabledContracts, EnabledContracts Classes: Ignorer
Class Method Summary collapse
- .included(base) ⇒ Object private
Class Method Details
.included(base) ⇒ Object
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/nanoc/base/contracts_support.rb', line 37 def self.included(base) contracts_loadable = begin require 'contracts' true rescue LoadError false end should_enable = contracts_loadable && !ENV.key?('DISABLE_CONTRACTS') if should_enable unless base.include?(::Contracts::Core) base.include(::Contracts::Core) base.extend(EnabledContracts) base.const_set('C', ::Contracts) end else base.extend(DisabledContracts) base.const_set('C', DisabledContracts) end end |