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
2475 2476 2477 2478 2479 2480 2481 2482 2483 2484 |
# File 'lib/schema.rb', line 2475 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
2486 2487 2488 |
# File 'lib/schema.rb', line 2486 def self.from_json!(json) from_dynamic!(JSON.parse(json)) end |
Instance Method Details
#to_dynamic ⇒ Object
2490 2491 2492 2493 2494 2495 2496 |
# File 'lib/schema.rb', line 2490 def to_dynamic if !enum.nil? enum elsif !step1.nil? step1.to_dynamic end end |
#to_json(options = nil) ⇒ Object
2498 2499 2500 |
# File 'lib/schema.rb', line 2498 def to_json( = nil) JSON.generate(to_dynamic, ) end |