Class: DependsOn
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- DependsOn
- Defined in:
- lib/schema.rb
Overview
The step keys for a step to depend on
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_dynamic!(d) ⇒ Object
387 388 389 390 391 392 393 394 395 396 397 |
# File 'lib/schema.rb', line 387 def self.from_dynamic!(d) return new(null: d, union_array: nil, string: nil) if schema[:null].right.valid? d return new(string: d, union_array: nil, null: nil) if schema[:string].right.valid? d begin value = d.map { |x| DependsOnElement.from_dynamic!(x) } return new(union_array: value, null: nil, string: nil) if schema[:union_array].right.valid? value rescue StandardError end raise "Invalid union" end |
.from_json!(json) ⇒ Object
399 400 401 |
# File 'lib/schema.rb', line 399 def self.from_json!(json) from_dynamic!(JSON.parse(json)) end |
Instance Method Details
#to_dynamic ⇒ Object
403 404 405 406 407 408 409 |
# File 'lib/schema.rb', line 403 def to_dynamic if !string.nil? string elsif !union_array.nil? union_array.map(&:to_dynamic) end end |
#to_json(options = nil) ⇒ Object
411 412 413 |
# File 'lib/schema.rb', line 411 def to_json( = nil) JSON.generate(to_dynamic, ) end |