Sha256: 8484dc3a3354459e36d1f904d9ae4f6860d0b8e3a2c3b05f3589ee690f8b03bd
Contents?: true
Size: 1.08 KB
Versions: 6
Compression:
Stored size: 1.08 KB
Contents
module Datacaster module Runtimes class StructureCleaner < Base attr_reader :checked_schema def initialize(*) super @checked_schema = {} @should_check_stack = [false] @pointer_stack = [@checked_schema] end # Array checked schema are the same as hash one, where # instead of keys there are array indicies def checked_key!(key) if @ignore return yield if block_given? return end @pointer_stack.last[key] ||= {} @pointer_stack.push(@pointer_stack.last[key]) @should_check_stack.push(false) result = yield if block_given? was_checked = @should_check_stack.pop @pointer_stack.pop @pointer_stack.last[key] = true unless was_checked result end def will_check! @should_check_stack[-1] = true end def ignore_checks!(&block) @ignore = true result = yield @ignore = false result end def unchecked? @should_check_stack == [false] end end end end
Version data entries
6 entries across 6 versions & 1 rubygems