Sha256: 19f33ead5c1555707b0c933ac3b46bf5a17888152711aad1a1e82d5ab6168ce0

Contents?: true

Size: 416 Bytes

Versions: 16

Compression:

Stored size: 416 Bytes

Contents

# frozen_string_literal: true

module Paquito
  class CoderChain
    def initialize(*coders)
      @coders = coders.flatten.map { |c| Paquito.cast(c) }
    end

    def dump(object)
      payload = object
      @coders.each { |c| payload = c.dump(payload) }
      payload
    end

    def load(payload)
      object = payload
      @coders.reverse_each { |c| object = c.load(object) }
      object
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
paquito-0.10.0 lib/paquito/coder_chain.rb
paquito-0.9.2 lib/paquito/coder_chain.rb
paquito-0.9.1 lib/paquito/coder_chain.rb
paquito-0.9.0 lib/paquito/coder_chain.rb
paquito-0.8.0 lib/paquito/coder_chain.rb
paquito-0.7.0 lib/paquito/coder_chain.rb
paquito-0.6.2 lib/paquito/coder_chain.rb
paquito-0.6.1 lib/paquito/coder_chain.rb
paquito-0.6.0 lib/paquito/coder_chain.rb
paquito-0.5.0 lib/paquito/coder_chain.rb
paquito-0.4.0 lib/paquito/coder_chain.rb
paquito-0.3.1 lib/paquito/coder_chain.rb
paquito-0.3.0 lib/paquito/coder_chain.rb
paquito-0.2.1 lib/paquito/coder_chain.rb
paquito-0.2.0 lib/paquito/coder_chain.rb
paquito-0.1.0 lib/paquito/coder_chain.rb