Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/varify/hash.rb

Instance Method Summary collapse

Instance Method Details

#varify(key, options = {}) ⇒ Object

Extends Hash object to add support for Hash.varify to extract the hash

Examples:

Extract a value

{a:'b',c:'d'}.varify(:a,required:true, is_a:String)
{a:'b',c:['d','e']}.varify(:b,required:true, is_a:Array[String])

Parameters:

  • key (Symbol)

    The hash key you would like to pull and verify

  • options (Hash) (defaults to: {})

    The key/value pairs of validators you’d like to run



10
11
12
# File 'lib/varify/hash.rb', line 10

def varify(key, options = {})
  Varify::Base.varify(key, self, options)
end