Sha256: a801037263c5e8ae16d9543078b2c8e172eab5dc0ac2386782120c328c5b354f
Contents?: true
Size: 772 Bytes
Versions: 1
Compression:
Stored size: 772 Bytes
Contents
# lib/lutaml/model/mapping_rule.rb module Lutaml module Model class MappingRule attr_reader :name, :to, :render_nil, :custom_methods, :delegate def initialize(name, to:, render_nil: false, with: {}, delegate: nil) @name = name @to = to @render_nil = render_nil @custom_methods = with @delegate = delegate end alias from name def serialize(model, value) if custom_methods[:to] model.send(custom_methods[:to], model, value) else value end end def deserialize(model, doc) if custom_methods[:from] model.send(custom_methods[:from], model, doc) else doc[name.to_s] end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
lutaml-model-0.1.0 | lib/lutaml/model/mapping_rule.rb |