Sha256: 11916f558b4a6d7a99ad495422d71b4ed041470b0d152de7753359aa2aa92607
Contents?: true
Size: 581 Bytes
Versions: 1
Compression:
Stored size: 581 Bytes
Contents
require "set" require "membrane/errors" require "membrane/schemas/base" class Membrane::Schemas::Bool < Membrane::Schemas::Base def validate(object) BoolValidator.new(object).validate end class BoolValidator TRUTH_VALUES = Set.new([true, false]) def initialize(object) @object = object end def validate if !TRUTH_VALUES.include?(@object) fail! end end private def fail! emsg = "Expected instance of true or false, given #{@object}" raise Membrane::SchemaValidationError.new(emsg) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
membrane-0.0.4 | lib/membrane/schemas/bool.rb |