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.
338 339 340 |
# File 'lib/contracts/builtin_contracts.rb', line 338 def initialize(contract) @contract = contract end |
Instance Attribute Details
#contract ⇒ Object (readonly)
Returns the value of attribute contract.
337 338 339 |
# File 'lib/contracts/builtin_contracts.rb', line 337 def contract @contract end |
Instance Method Details
#test_data ⇒ Object
350 351 352 353 354 355 356 |
# File 'lib/contracts/builtin_contracts.rb', line 350 def test_data [ [], [Testable.test_data(@contract)], [Testable.test_data(@contract), Testable.test_data(@contract)] ] end |
#testable? ⇒ Boolean
346 347 348 |
# File 'lib/contracts/builtin_contracts.rb', line 346 def testable? Testable.testable? @contract end |
#to_s ⇒ Object
342 343 344 |
# File 'lib/contracts/builtin_contracts.rb', line 342 def to_s "Args[#{@contract}]" end |