Class: ManualUnion
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- ManualUnion
- Defined in:
- lib/schema.rb
Overview
Whether to allow a job to be retried manually
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_dynamic!(d) ⇒ Object
923 924 925 926 927 928 929 930 931 932 933 |
# File 'lib/schema.rb', line 923 def self.from_dynamic!(d) return new(bool: d, manual_class: nil, enum: nil) if schema[:bool].right.valid? d return new(enum: d, bool: nil, manual_class: nil) if schema[:enum].right.valid? d begin value = ManualClass.from_dynamic!(d) return new(manual_class: value, bool: nil, enum: nil) if schema[:manual_class].right.valid? value rescue StandardError end raise "Invalid union" end |
.from_json!(json) ⇒ Object
935 936 937 |
# File 'lib/schema.rb', line 935 def self.from_json!(json) from_dynamic!(JSON.parse(json)) end |
Instance Method Details
#to_dynamic ⇒ Object
939 940 941 942 943 944 945 946 947 |
# File 'lib/schema.rb', line 939 def to_dynamic if !bool.nil? bool elsif !enum.nil? enum elsif !manual_class.nil? manual_class.to_dynamic end end |
#to_json(options = nil) ⇒ Object
949 950 951 |
# File 'lib/schema.rb', line 949 def to_json( = nil) JSON.generate(to_dynamic, ) end |