Class: Contracts::Args
- Inherits:
-
CallableClass
- Object
- CallableClass
- Contracts::Args
- Defined in:
- lib/contracts/builtin_contracts.rb
Overview
Used for *args
(variadic functions). Takes a contract and uses it to validate every element passed in through *args
. Example: Args[Or[String, Num]]
Instance Attribute Summary collapse
-
#contract ⇒ Object
readonly
Returns the value of attribute contract.
Instance Method Summary collapse
-
#initialize(contract) ⇒ Args
constructor
A new instance of Args.
- #test_data ⇒ Object
- #testable? ⇒ Boolean
- #to_s ⇒ Object
Methods inherited from CallableClass
Constructor Details
#initialize(contract) ⇒ Args
Returns a new instance of Args.
294 295 296 |
# File 'lib/contracts/builtin_contracts.rb', line 294 def initialize(contract) @contract = contract end |
Instance Attribute Details
#contract ⇒ Object (readonly)
Returns the value of attribute contract.
293 294 295 |
# File 'lib/contracts/builtin_contracts.rb', line 293 def contract @contract end |
Instance Method Details
#test_data ⇒ Object
306 307 308 |
# File 'lib/contracts/builtin_contracts.rb', line 306 def test_data [[], [Testable.test_data(@contract)], [Testable.test_data(@contract), Testable.test_data(@contract)]] end |
#testable? ⇒ Boolean
302 303 304 |
# File 'lib/contracts/builtin_contracts.rb', line 302 def testable? Testable.testable? @contract end |
#to_s ⇒ Object
298 299 300 |
# File 'lib/contracts/builtin_contracts.rb', line 298 def to_s "Args[#{@contract}]" end |