Sha256: 2207593402a98c98034b7049ca76f50c563abfded284bd8e0338fb3688829882
Contents?: true
Size: 643 Bytes
Versions: 1
Compression:
Stored size: 643 Bytes
Contents
module Inspector class Validator def initialize(metadata_map, walker, type_metadata_class) @metadata_map = metadata_map @walker = walker @type_metadata_class = type_metadata_class end def valid(type, &block) metadata = @type_metadata_class.new(type) if block_given? block.arity == 1 ? yield(metadata) : metadata.instance_eval(&block) end @metadata_map[type] = metadata nil end def validate(object, opts = {}) type = opts.fetch(:as) { object.class } metadata = @metadata_map[type] @walker.walk_object(metadata, object) end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
object-inspector-0.1.0 | lib/inspector/validator.rb |