ValidatedHash

Public Instance Methods

validate_all(*keys) click to toggle source

Raises an exception if any of the keys provided are not found in the hash

# File lib/monkeybars/validated_hash.rb, line 10
def validate_all(*keys)
  keys.each {|key| raise InvalidHashKeyError.new("#{key} is required for this hash") unless self.keys.member?(key)}
end
validate_none(*keys) click to toggle source

Raises an exception if any of the keys provided are found in the hash

# File lib/monkeybars/validated_hash.rb, line 15
def validate_none(*keys)
  keys.each {|key| raise InvalidHashKeyError.new("#{key} is not allowed for this hash") if self.keys.member?(key)}
end
validate_only(*keys) click to toggle source

Raises an exception if a key in the hash does not exist in the list of valid keys

# File lib/monkeybars/validated_hash.rb, line 5
def validate_only(*keys)
  self.keys.each {|key| raise InvalidHashKeyError.new("#{key} is not a valid key for this hash") unless keys.member?(key)}
end

[Validate]

Generated with the Darkfish Rdoc Generator 2.