Class: MatrixElement
- Inherits:
-
Dry::Struct
- Object
- Dry::Struct
- MatrixElement
- Defined in:
- lib/schema.rb
Overview
List of elements for simple single-dimension Build Matrix
List of existing or new elements for single-dimension Build Matrix
List of elements for single-dimension Build Matrix
List of elements for this Build Matrix dimension
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.from_dynamic!(d) ⇒ Object
1014 1015 1016 1017 1018 1019 1020 |
# File 'lib/schema.rb', line 1014 def self.from_dynamic!(d) return new(bool: d, integer: nil, string: nil) if schema[:bool].right.valid? d return new(integer: d, bool: nil, string: nil) if schema[:integer].right.valid? d return new(string: d, bool: nil, integer: nil) if schema[:string].right.valid? d raise "Invalid union" end |
.from_json!(json) ⇒ Object
1022 1023 1024 |
# File 'lib/schema.rb', line 1022 def self.from_json!(json) from_dynamic!(JSON.parse(json)) end |
Instance Method Details
#to_dynamic ⇒ Object
1026 1027 1028 1029 1030 1031 1032 1033 1034 |
# File 'lib/schema.rb', line 1026 def to_dynamic if !bool.nil? bool elsif !integer.nil? integer elsif !string.nil? string end end |
#to_json(options = nil) ⇒ Object
1036 1037 1038 |
# File 'lib/schema.rb', line 1036 def to_json( = nil) JSON.generate(to_dynamic, ) end |