Class: Paquito::CoderChain
- Inherits:
-
Object
- Object
- Paquito::CoderChain
- Defined in:
- lib/paquito/coder_chain.rb
Instance Method Summary collapse
- #dump(object) ⇒ Object
-
#initialize(*coders) ⇒ CoderChain
constructor
A new instance of CoderChain.
- #load(payload) ⇒ Object
Constructor Details
#initialize(*coders) ⇒ CoderChain
Returns a new instance of CoderChain.
5 6 7 8 |
# File 'lib/paquito/coder_chain.rb', line 5 def initialize(*coders) @coders = coders.flatten.map { |c| Paquito.cast(c) } @reverse_coders = @coders.reverse end |
Instance Method Details
#dump(object) ⇒ Object
10 11 12 13 14 |
# File 'lib/paquito/coder_chain.rb', line 10 def dump(object) payload = object @coders.each { |c| payload = c.dump(payload) } payload end |
#load(payload) ⇒ Object
16 17 18 19 20 |
# File 'lib/paquito/coder_chain.rb', line 16 def load(payload) object = payload @reverse_coders.each { |c| object = c.load(object) } object end |