Class: NotifyElement
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- NotifyElement
- Defined in:
- lib/schema.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_dynamic!(d) ⇒ Object
1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 |
# File 'lib/schema.rb', line 1460 def self.from_dynamic!(d) return new(enum: d, notify_class: nil) if schema[:enum].right.valid? d begin value = NotifyClass.from_dynamic!(d) return new(notify_class: value, enum: nil) if schema[:notify_class].right.valid? value rescue StandardError end raise "Invalid union" end |
.from_json!(json) ⇒ Object
1471 1472 1473 |
# File 'lib/schema.rb', line 1471 def self.from_json!(json) from_dynamic!(JSON.parse(json)) end |
Instance Method Details
#to_dynamic ⇒ Object
1475 1476 1477 1478 1479 1480 1481 |
# File 'lib/schema.rb', line 1475 def to_dynamic if !enum.nil? enum elsif !notify_class.nil? notify_class.to_dynamic end end |
#to_json(options = nil) ⇒ Object
1483 1484 1485 |
# File 'lib/schema.rb', line 1483 def to_json( = nil) JSON.generate(to_dynamic, ) end |