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
2717 2718 2719 2720 2721 2722 2723 2724 2725 2726 |
# File 'lib/schema.rb', line 2717 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
2728 2729 2730 |
# File 'lib/schema.rb', line 2728 def self.from_json!(json) from_dynamic!(JSON.parse(json)) end |
Instance Method Details
#to_dynamic ⇒ Object
2732 2733 2734 2735 2736 2737 2738 |
# File 'lib/schema.rb', line 2732 def to_dynamic if !enum.nil? enum elsif !group_step_class.nil? group_step_class.to_dynamic end end |
#to_json(options = nil) ⇒ Object
2740 2741 2742 |
# File 'lib/schema.rb', line 2740 def to_json( = nil) JSON.generate(to_dynamic, ) end |