Sha256: 29232892bf7c0a7b1890aee209a6f147adff0867051d67ae12e50a9d8e4e0620
Contents?: true
Size: 750 Bytes
Versions: 69
Compression:
Stored size: 750 Bytes
Contents
module FlydataCore module OptionValidator def self.included(base) base.extend(ClassMethods) end def validate_options(o, options = nil) self.class.validate_options(o, options) end module ClassMethods def validate_options(o, options = nil) if (options.nil?) unless defined?(self::OPTIONS) raise "validate_options needs OPTIONS hash defined" end options = self::OPTIONS end result = o.clone options.keys.each do |k| unless (result.has_key?(k)) if (options[k] != :mandatory) result[k] = options[k] else raise "Mandatory option #{k} is missing" end end end result end end end end
Version data entries
69 entries across 69 versions & 1 rubygems