Class: Label
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- Label
- Defined in:
- lib/schema.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_dynamic!(d) ⇒ Object
2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 |
# File 'lib/schema.rb', line 2232 def self.from_dynamic!(d) return new(null: d, wait_step: nil, string: nil) if schema[:null].right.valid? d return new(string: d, wait_step: nil, null: nil) if schema[:string].right.valid? d begin value = WaitStep.from_dynamic!(d) return new(wait_step: value, null: nil, string: nil) if schema[:wait_step].right.valid? value rescue StandardError end raise "Invalid union" end |
.from_json!(json) ⇒ Object
2244 2245 2246 |
# File 'lib/schema.rb', line 2244 def self.from_json!(json) from_dynamic!(JSON.parse(json)) end |
Instance Method Details
#to_dynamic ⇒ Object
2248 2249 2250 2251 2252 2253 2254 |
# File 'lib/schema.rb', line 2248 def to_dynamic if !string.nil? string elsif !wait_step.nil? wait_step.to_dynamic end end |
#to_json(options = nil) ⇒ Object
2256 2257 2258 |
# File 'lib/schema.rb', line 2256 def to_json( = nil) JSON.generate(to_dynamic, ) end |