Class: Automatic
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- Automatic
- Defined in:
- lib/schema.rb
Overview
Whether to allow a job to retry automatically. If set to true, the retry conditions are set to the default value.
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_dynamic!(d) ⇒ Object
838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 |
# File 'lib/schema.rb', line 838 def self.from_dynamic!(d) begin value = AutomaticRetry.from_dynamic!(d) if schema[:automatic_retry].right.valid? value return new(automatic_retry: value, automatic_retry_array: nil, bool: nil, enum: nil) end rescue StandardError end begin value = d.map { |x| AutomaticRetry.from_dynamic!(x) } if schema[:automatic_retry_array].right.valid? value return new(automatic_retry_array: value, bool: nil, automatic_retry: nil, enum: nil) end rescue StandardError end return new(bool: d, automatic_retry_array: nil, automatic_retry: nil, enum: nil) if schema[:bool].right.valid? d return new(enum: d, automatic_retry_array: nil, bool: nil, automatic_retry: nil) if schema[:enum].right.valid? d raise "Invalid union" end |
.from_json!(json) ⇒ Object
859 860 861 |
# File 'lib/schema.rb', line 859 def self.from_json!(json) from_dynamic!(JSON.parse(json)) end |
Instance Method Details
#to_dynamic ⇒ Object
863 864 865 866 867 868 869 870 871 872 873 |
# File 'lib/schema.rb', line 863 def to_dynamic if !automatic_retry.nil? automatic_retry.to_dynamic elsif !automatic_retry_array.nil? automatic_retry_array.map(&:to_dynamic) elsif !bool.nil? bool elsif !enum.nil? enum end end |
#to_json(options = nil) ⇒ Object
875 876 877 |
# File 'lib/schema.rb', line 875 def to_json( = nil) JSON.generate(to_dynamic, ) end |