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
1012 1013 1014 1015 1016 1017 1018 |
# File 'lib/schema.rb', line 1012 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
1020 1021 1022 |
# File 'lib/schema.rb', line 1020 def self.from_json!(json) from_dynamic!(JSON.parse(json)) end |
Instance Method Details
#to_dynamic ⇒ Object
1024 1025 1026 1027 1028 1029 1030 1031 1032 |
# File 'lib/schema.rb', line 1024 def to_dynamic if !bool.nil? bool elsif !integer.nil? integer elsif !string.nil? string end end |
#to_json(options = nil) ⇒ Object
1034 1035 1036 |
# File 'lib/schema.rb', line 1034 def to_json( = nil) JSON.generate(to_dynamic, ) end |