Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/contracts/builtin_contracts.rb

Instance Method Summary collapse

Instance Method Details

#test_dataObject



354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
# File 'lib/contracts/builtin_contracts.rb', line 354

def test_data
  keys = self.keys
  _vals = keys.map do |key|
    ret = Testable.test_data(self[key])
    if ret.is_a? Array
      ret
    else
      [ret]
    end
  end
  all_vals = Testable.product(_vals)
  hashes = []
  all_vals.each do |vals|
    hash = {}
    keys.zip(vals).each do |key, val|
      hash[key] = val
    end
    hashes << hash
  end
  hashes
end

#testable?Boolean

Returns:

  • (Boolean)


348
349
350
351
352
# File 'lib/contracts/builtin_contracts.rb', line 348

def testable?
  self.values.all? do |val|
    Testable.testable?(val)
  end
end