Class: Disposable::Twin::Schema
- Inherits:
-
Object
- Object
- Disposable::Twin::Schema
- Defined in:
- lib/disposable/twin/schema.rb
Overview
TODO: this needs tests and should probably go to Representable. we can move tests from Reform for that.
Class Method Summary collapse
-
.from(source_class, options) ⇒ Object
TODO: can we re-use this for all the decorator logic in #validate, etc?.
Class Method Details
.from(source_class, options) ⇒ Object
TODO: can we re-use this for all the decorator logic in #validate, etc?
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/disposable/twin/schema.rb', line 3 def self.from(source_class, ) # TODO: can we re-use this for all the decorator logic in #validate, etc? representer = Class.new([:superclass]) representer.send :include, *[:include] source_representer = [:representer_from].call(source_class) source_representer.representable_attrs.each do |dfn| = dfn[[:options_from]] || {} # e.g. deserializer: {..}. = dfn.instance_variable_get(:@options).merge() from_scalar!(, dfn, , representer) && next unless dfn[:extend] from_inline!(, dfn, , representer) end representer end |