Class BinaryBlocker::OneOfEncoder
In: lib/blocker.rb
Parent: Encoder
GroupEncoder ListOfEncoder Blocker FixedArrayEncoder CountedArrayEncoder Encoder SimpleEncoder BitFieldEncoder OneOfEncoder PackedNumberEncoder PackedDateEncoder PackedDateTimeEncoder FixedStringEncoder FixedUTF16StringEncoder BinaryBlocker Module: BinaryBlocker

Methods

Public Class methods

[Source]

     # File lib/blocker.rb, line 500
500:     def initialize(classes, *opts)
501:       @classes = classes.map { |o| o.call(*opts) }
502:       @obj = nil
503:       super(*opts)
504:     end

Public Instance methods

[Source]

     # File lib/blocker.rb, line 496
496:     def inspect
497:       "OneOf #{@classes.join(',')} -> #{@obj.class} -> #{@obj.inspect}" 
498:     end

[Source]

     # File lib/blocker.rb, line 506
506:     def internal_block(val)
507:       val.block if val
508:     end

[Source]

     # File lib/blocker.rb, line 510
510:     def internal_deblock(io)
511:       @obj = nil
512:       with_guarded_io_pos(io) do
513:         @classes.each do |obj|
514:           if obj.deblock(io)
515:             @obj = obj
516:             break 
517:           end 
518:           false
519:         end
520:       end       
521:       @obj
522:     end

[Source]

     # File lib/blocker.rb, line 524
524:     def method_missing(sym, *args)
525:       if @obj
526:         @obj.send sym, *args
527:       else
528:         super
529:       end
530:     end

[Source]

     # File lib/blocker.rb, line 532
532:     def valid?
533:       @obj && @obj.valid?
534:     end

[Validate]