Class: Contracts::Builtin::SplatArgs

Inherits:
CallableClass show all
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: SplatArgs[Or[String, Num]]

Direct Known Subclasses

Args

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods inherited from CallableClass

[]

Constructor Details

#initialize(contract) ⇒ SplatArgs

Returns a new instance of SplatArgs.



326
327
328
# File 'lib/contracts/builtin_contracts.rb', line 326

def initialize(contract)
  @contract = contract
end

Instance Attribute Details

#contractObject (readonly)

Returns the value of attribute contract.



325
326
327
# File 'lib/contracts/builtin_contracts.rb', line 325

def contract
  @contract
end

Instance Method Details

#to_sObject



330
331
332
# File 'lib/contracts/builtin_contracts.rb', line 330

def to_s
  "SplatArgs[#{@contract}]"
end