Class: Contracts::Args
- Inherits:
-
CallableClass
- Object
- CallableClass
- Contracts::Args
- Defined in:
- lib/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.
293 294 295 |
# File 'lib/builtin_contracts.rb', line 293 def initialize(contract) @contract = contract end |
Instance Attribute Details
#contract ⇒ Object (readonly)
Returns the value of attribute contract.
292 293 294 |
# File 'lib/builtin_contracts.rb', line 292 def contract @contract end |
Instance Method Details
#test_data ⇒ Object
305 306 307 |
# File 'lib/builtin_contracts.rb', line 305 def test_data [[], [Testable.test_data(@contract)], [Testable.test_data(@contract), Testable.test_data(@contract)]] end |
#testable? ⇒ Boolean
301 302 303 |
# File 'lib/builtin_contracts.rb', line 301 def testable? Testable.testable? @contract end |
#to_s ⇒ Object
297 298 299 |
# File 'lib/builtin_contracts.rb', line 297 def to_s "Args[#{@contract}]" end |