Class: Disposable::Rescheme
- Inherits:
-
Object
- Object
- Disposable::Rescheme
- Defined in:
- lib/disposable/rescheme.rb
Overview
Rescheme::from allows to copy a schema structure. This will create “fresh” inline schemas instead of inheriting/copying the original classes, making it a replication of the structure, only.
Options allow to customize the copied schema.
:exclude
: ignore options from original Definition when copying.
Provided block is run per newly created Definition.
Rescheme.from(...) { |dfn| dfn[:readable] = true }
Class Method Summary collapse
Instance Method Summary collapse
-
#from(source_class, options, &block) ⇒ Object
Builds a new representer (structure only) from source_class.
Class Method Details
.from(*args, &block) ⇒ Object
11 12 13 |
# File 'lib/disposable/rescheme.rb', line 11 def self.from(*args, &block) new.from(*args, &block) end |
Instance Method Details
#from(source_class, options, &block) ⇒ Object
Builds a new representer (structure only) from source_class.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/disposable/rescheme.rb', line 16 def from(source_class, , &block) # TODO: can we re-use this for all the decorator logic in #validate, etc? representer = build_representer() definitions = [:definitions_from].call(source_class) definitions.each do |dfn| next if ([:exclude_properties]||{}).include?(dfn[:name].to_sym) dfn = build_definition!(, dfn, representer, &block) evaluate_block!(, dfn, &block) end representer end |