Class: Input
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- Input
- Defined in:
- lib/schema.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_dynamic!(d) ⇒ Object
1843 1844 1845 1846 1847 1848 1849 1850 1851 1852 |
# File 'lib/schema.rb', line 1843 def self.from_dynamic!(d) begin value = InputStep.from_dynamic!(d) return new(input_step: value, string: nil) if schema[:input_step].right.valid? value rescue StandardError end return new(string: d, input_step: nil) if schema[:string].right.valid? d raise "Invalid union" end |
.from_json!(json) ⇒ Object
1854 1855 1856 |
# File 'lib/schema.rb', line 1854 def self.from_json!(json) from_dynamic!(JSON.parse(json)) end |
Instance Method Details
#to_dynamic ⇒ Object
1858 1859 1860 1861 1862 1863 1864 |
# File 'lib/schema.rb', line 1858 def to_dynamic if !input_step.nil? input_step.to_dynamic elsif !string.nil? string end end |
#to_json(options = nil) ⇒ Object
1866 1867 1868 |
# File 'lib/schema.rb', line 1866 def to_json( = nil) JSON.generate(to_dynamic, ) end |