Class: SchemaStep
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- SchemaStep
- Defined in:
- lib/schema.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_dynamic!(d) ⇒ Object
2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 |
# File 'lib/schema.rb', line 2719 def self.from_dynamic!(d) return new(enum: d, group_step_class: nil) if schema[:enum].right.valid? d begin value = GroupStepClass.from_dynamic!(d) return new(group_step_class: value, enum: nil) if schema[:group_step_class].right.valid? value rescue StandardError end raise "Invalid union" end |
.from_json!(json) ⇒ Object
2730 2731 2732 |
# File 'lib/schema.rb', line 2730 def self.from_json!(json) from_dynamic!(JSON.parse(json)) end |
Instance Method Details
#to_dynamic ⇒ Object
2734 2735 2736 2737 2738 2739 2740 |
# File 'lib/schema.rb', line 2734 def to_dynamic if !enum.nil? enum elsif !group_step_class.nil? group_step_class.to_dynamic end end |
#to_json(options = nil) ⇒ Object
2742 2743 2744 |
# File 'lib/schema.rb', line 2742 def to_json( = nil) JSON.generate(to_dynamic, ) end |