Module: Dry::Schema::ResultDecorator
- Defined in:
- lib/dry/schema/result_decorator.rb
Overview
This decorator allows to serialize Dry::Schema::Result objects by storing the data and processor so they can be run again during deserialization.
Class Method Summary collapse
Class Method Details
.included(base) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/dry/schema/result_decorator.rb', line 11 def self.included(base) base.class_eval do option :processor def _dump(_) Marshal.dump( { processor: processor.class, data: to_h } ) end def self._load(data) data = Marshal.load(data) data[:processor].new.call(data[:data]) end end end |