Class: Contracts::Builtin::CallableClass

Inherits:
Object
  • Object
show all
Includes:
Formatters
Defined in:
lib/contracts-ruby2/lib/contracts/builtin_contracts.rb,
lib/contracts-ruby3/lib/contracts/builtin_contracts.rb

Overview

Use this when you are writing your own contract classes. Allows your contract to be called with [] instead of .new:

Old: Or.new(param1, param2)

New: Or[param1, param2]

Of course, .new still works.

Class Method Summary collapse

Class Method Details

.[](*vals) ⇒ Object



89
90
91
# File 'lib/contracts-ruby2/lib/contracts/builtin_contracts.rb', line 89

def self.[](*vals)
  new(*vals)
end