Sha256: 0ff3525d2d14f1e7b866915f4b4ebaf97f24781717ccfb1155f7f1e5de7d63bf
Contents?: true
Size: 844 Bytes
Versions: 1
Compression:
Stored size: 844 Bytes
Contents
# type_checks.rb -- checks whether provided is a valid instance of a specified type # # Provides validation for standard JSON type require 'rspec/expectations' # This will be made extensible so it can replace current domain specific check logic class TypeChecks include RSpec::Matchers def initialize @map = { Object: be_a_kind_of(Hash), String: be_a_kind_of(String), Number: be_a_kind_of(Numeric), Integer: be_a_kind_of(Integer), Array: be_a_kind_of(Array), DateTime: be_a_kind_of(Time), Boolean: satisfy{|it| it == true || it == false } } end def for_type(type) @map[type.to_sym] || raise("Unsupported type #{type}") end end module TypeChecking def type_checks @type_check ||= TypeChecks.new end def type_check_for(type) type_checks.for_type(type) end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
brine-dsl-0.9.0 | lib/brine/type_checks.rb |