Module: Ree::Contracts

Defined in:
lib/ree/contracts.rb,
lib/ree/contracts/core.rb,
lib/ree/contracts/utils.rb,
lib/ree/contracts/engine.rb,
lib/ree/contracts/validators.rb,
lib/ree/contracts/truncatable.rb,
lib/ree/contracts/contractable.rb,
lib/ree/contracts/engine_proxy.rb,
lib/ree/contracts/errors/error.rb,
lib/ree/contracts/arg_contracts.rb,
lib/ree/contracts/arg_contracts/eq.rb,
lib/ree/contracts/arg_contracts/or.rb,
lib/ree/contracts/method_decorator.rb,
lib/ree/contracts/arg_contracts/any.rb,
lib/ree/contracts/arg_contracts/bool.rb,
lib/ree/contracts/arg_contracts/none.rb,
lib/ree/contracts/arg_contracts/block.rb,
lib/ree/contracts/arg_contracts/nilor.rb,
lib/ree/contracts/arg_contracts/splat.rb,
lib/ree/contracts/contract_definition.rb,
lib/ree/contracts/arg_contracts/ksplat.rb,
lib/ree/contracts/arg_contracts/kwargs.rb,
lib/ree/contracts/arg_contracts/set_of.rb,
lib/ree/contracts/arg_contracts/exactly.rb,
lib/ree/contracts/arg_contracts/hash_of.rb,
lib/ree/contracts/called_args_validator.rb,
lib/ree/contracts/errors/contract_error.rb,
lib/ree/contracts/arg_contracts/array_of.rb,
lib/ree/contracts/arg_contracts/optblock.rb,
lib/ree/contracts/arg_contracts/range_of.rb,
lib/ree/contracts/arg_contracts/splat_of.rb,
lib/ree/contracts/arg_contracts/squarable.rb,
lib/ree/contracts/arg_contracts/respond_to.rb,
lib/ree/contracts/arg_contracts/subclass_of.rb,
lib/ree/contracts/errors/bad_contract_error.rb,
lib/ree/contracts/validators/base_validator.rb,
lib/ree/contracts/validators/hash_validator.rb,
lib/ree/contracts/validators/proc_validator.rb,
lib/ree/contracts/validators/array_validator.rb,
lib/ree/contracts/validators/class_validator.rb,
lib/ree/contracts/validators/range_validator.rb,
lib/ree/contracts/validators/valid_validator.rb,
lib/ree/contracts/validators/regexp_validator.rb,
lib/ree/contracts/errors/return_contract_error.rb,
lib/ree/contracts/validators/default_validator.rb

Defined Under Namespace

Modules: ArgContracts, Contractable, Core, Truncatable, Utils Classes: ArrayValidator, BadContractError, BaseValidator, CalledArgsValidator, ClassValidator, ContractDefinition, ContractError, DefaultValidator, Engine, EngineProxy, Error, HashValidator, MethodDecorator, ProcValidator, RangeValidator, RegexpValidator, ReturnContractError, ValidValidator, Validators

Class Method Summary collapse

Class Method Details

.get_method_decorator(target, method_name, scope: :instance) ⇒ Object



37
38
39
40
41
42
43
44
# File 'lib/ree/contracts.rb', line 37

def self.get_method_decorator(target, method_name, scope: :instance)
  unless scope == :instance || scope == :class
    raise Ree::Error.new(':scope should be either :class or :instance', :invalid_dsl_usage)
  end

  decorator_id = MethodDecorator.decorator_id(target, method_name, scope == :class)
  MethodDecorator.get_decorator(decorator_id)
end

.no_contracts?Boolean

Returns:

  • (Boolean)


33
34
35
# File 'lib/ree/contracts.rb', line 33

def self.no_contracts?
  ENV["NO_CONTRACTS"]
end