Class: BlockStepStep
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- BlockStepStep
- Defined in:
- lib/schema.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_dynamic!(d) ⇒ Object
2477 2478 2479 2480 2481 2482 2483 2484 2485 2486 |
# File 'lib/schema.rb', line 2477 def self.from_dynamic!(d) return new(enum: d, step1: nil) if schema[:enum].right.valid? d begin value = Step1.from_dynamic!(d) return new(step1: value, enum: nil) if schema[:step1].right.valid? value rescue StandardError end raise "Invalid union" end |
.from_json!(json) ⇒ Object
2488 2489 2490 |
# File 'lib/schema.rb', line 2488 def self.from_json!(json) from_dynamic!(JSON.parse(json)) end |
Instance Method Details
#to_dynamic ⇒ Object
2492 2493 2494 2495 2496 2497 2498 |
# File 'lib/schema.rb', line 2492 def to_dynamic if !enum.nil? enum elsif !step1.nil? step1.to_dynamic end end |
#to_json(options = nil) ⇒ Object
2500 2501 2502 |
# File 'lib/schema.rb', line 2500 def to_json( = nil) JSON.generate(to_dynamic, ) end |